Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /* Copyright (c) 2019, Intel Corporation. */
0003 
0004 #ifndef _ICE_TXRX_LIB_H_
0005 #define _ICE_TXRX_LIB_H_
0006 #include "ice.h"
0007 
0008 /**
0009  * ice_test_staterr - tests bits in Rx descriptor status and error fields
0010  * @status_err_n: Rx descriptor status_error0 or status_error1 bits
0011  * @stat_err_bits: value to mask
0012  *
0013  * This function does some fast chicanery in order to return the
0014  * value of the mask which is really only used for boolean tests.
0015  * The status_error_len doesn't need to be shifted because it begins
0016  * at offset zero.
0017  */
0018 static inline bool
0019 ice_test_staterr(__le16 status_err_n, const u16 stat_err_bits)
0020 {
0021     return !!(status_err_n & cpu_to_le16(stat_err_bits));
0022 }
0023 
0024 static inline __le64
0025 ice_build_ctob(u64 td_cmd, u64 td_offset, unsigned int size, u64 td_tag)
0026 {
0027     return cpu_to_le64(ICE_TX_DESC_DTYPE_DATA |
0028                (td_cmd    << ICE_TXD_QW1_CMD_S) |
0029                (td_offset << ICE_TXD_QW1_OFFSET_S) |
0030                ((u64)size << ICE_TXD_QW1_TX_BUF_SZ_S) |
0031                (td_tag    << ICE_TXD_QW1_L2TAG1_S));
0032 }
0033 
0034 /**
0035  * ice_get_vlan_tag_from_rx_desc - get VLAN from Rx flex descriptor
0036  * @rx_desc: Rx 32b flex descriptor with RXDID=2
0037  *
0038  * The OS and current PF implementation only support stripping a single VLAN tag
0039  * at a time, so there should only ever be 0 or 1 tags in the l2tag* fields. If
0040  * one is found return the tag, else return 0 to mean no VLAN tag was found.
0041  */
0042 static inline u16
0043 ice_get_vlan_tag_from_rx_desc(union ice_32b_rx_flex_desc *rx_desc)
0044 {
0045     u16 stat_err_bits;
0046 
0047     stat_err_bits = BIT(ICE_RX_FLEX_DESC_STATUS0_L2TAG1P_S);
0048     if (ice_test_staterr(rx_desc->wb.status_error0, stat_err_bits))
0049         return le16_to_cpu(rx_desc->wb.l2tag1);
0050 
0051     stat_err_bits = BIT(ICE_RX_FLEX_DESC_STATUS1_L2TAG2P_S);
0052     if (ice_test_staterr(rx_desc->wb.status_error1, stat_err_bits))
0053         return le16_to_cpu(rx_desc->wb.l2tag2_2nd);
0054 
0055     return 0;
0056 }
0057 
0058 /**
0059  * ice_xdp_ring_update_tail - Updates the XDP Tx ring tail register
0060  * @xdp_ring: XDP Tx ring
0061  *
0062  * This function updates the XDP Tx ring tail register.
0063  */
0064 static inline void ice_xdp_ring_update_tail(struct ice_tx_ring *xdp_ring)
0065 {
0066     /* Force memory writes to complete before letting h/w
0067      * know there are new descriptors to fetch.
0068      */
0069     wmb();
0070     writel_relaxed(xdp_ring->next_to_use, xdp_ring->tail);
0071 }
0072 
0073 void ice_finalize_xdp_rx(struct ice_tx_ring *xdp_ring, unsigned int xdp_res);
0074 int ice_xmit_xdp_buff(struct xdp_buff *xdp, struct ice_tx_ring *xdp_ring);
0075 int ice_xmit_xdp_ring(void *data, u16 size, struct ice_tx_ring *xdp_ring);
0076 void ice_release_rx_desc(struct ice_rx_ring *rx_ring, u16 val);
0077 void
0078 ice_process_skb_fields(struct ice_rx_ring *rx_ring,
0079                union ice_32b_rx_flex_desc *rx_desc,
0080                struct sk_buff *skb, u16 ptype);
0081 void
0082 ice_receive_skb(struct ice_rx_ring *rx_ring, struct sk_buff *skb, u16 vlan_tag);
0083 #endif /* !_ICE_TXRX_LIB_H_ */