// SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2013 - 2018 Intel Corporation. */ #include <linux/bpf_trace.h> #include <linux/net/intel/libie/rx.h> #include <linux/prefetch.h> #include <linux/sctp.h> #include <net/mpls.h> #include <net/xdp.h> #include "i40e_txrx_common.h" #include "i40e_trace.h" #include "i40e_xsk.h" #define I40E_TXD_CMD … /** * i40e_fdir - Generate a Flow Director descriptor based on fdata * @tx_ring: Tx ring to send buffer on * @fdata: Flow director filter data * @add: Indicate if we are adding a rule or deleting one * **/ static void i40e_fdir(struct i40e_ring *tx_ring, struct i40e_fdir_filter *fdata, bool add) { … } #define I40E_FD_CLEAN_DELAY … /** * i40e_program_fdir_filter - Program a Flow Director filter * @fdir_data: Packet data that will be filter parameters * @raw_packet: the pre-allocated packet buffer for FDir * @pf: The PF pointer * @add: True for add/update, False for remove **/ static int i40e_program_fdir_filter(struct i40e_fdir_filter *fdir_data, u8 *raw_packet, struct i40e_pf *pf, bool add) { … } /** * i40e_create_dummy_packet - Constructs dummy packet for HW * @dummy_packet: preallocated space for dummy packet * @ipv4: is layer 3 packet of version 4 or 6 * @l4proto: next level protocol used in data portion of l3 * @data: filter data * * Returns address of layer 4 protocol dummy packet. **/ static char *i40e_create_dummy_packet(u8 *dummy_packet, bool ipv4, u8 l4proto, struct i40e_fdir_filter *data) { … } /** * i40e_create_dummy_udp_packet - helper function to create UDP packet * @raw_packet: preallocated space for dummy packet * @ipv4: is layer 3 packet of version 4 or 6 * @l4proto: next level protocol used in data portion of l3 * @data: filter data * * Helper function to populate udp fields. **/ static void i40e_create_dummy_udp_packet(u8 *raw_packet, bool ipv4, u8 l4proto, struct i40e_fdir_filter *data) { … } /** * i40e_create_dummy_tcp_packet - helper function to create TCP packet * @raw_packet: preallocated space for dummy packet * @ipv4: is layer 3 packet of version 4 or 6 * @l4proto: next level protocol used in data portion of l3 * @data: filter data * * Helper function to populate tcp fields. **/ static void i40e_create_dummy_tcp_packet(u8 *raw_packet, bool ipv4, u8 l4proto, struct i40e_fdir_filter *data) { … } /** * i40e_create_dummy_sctp_packet - helper function to create SCTP packet * @raw_packet: preallocated space for dummy packet * @ipv4: is layer 3 packet of version 4 or 6 * @l4proto: next level protocol used in data portion of l3 * @data: filter data * * Helper function to populate sctp fields. **/ static void i40e_create_dummy_sctp_packet(u8 *raw_packet, bool ipv4, u8 l4proto, struct i40e_fdir_filter *data) { … } /** * i40e_prepare_fdir_filter - Prepare and program fdir filter * @pf: physical function to attach filter to * @fd_data: filter data * @add: add or delete filter * @packet_addr: address of dummy packet, used in filtering * @payload_offset: offset from dummy packet address to user defined data * @pctype: Packet type for which filter is used * * Helper function to offset data of dummy packet, program it and * handle errors. **/ static int i40e_prepare_fdir_filter(struct i40e_pf *pf, struct i40e_fdir_filter *fd_data, bool add, char *packet_addr, int payload_offset, u8 pctype) { … } /** * i40e_change_filter_num - Prepare and program fdir filter * @ipv4: is layer 3 packet of version 4 or 6 * @add: add or delete filter * @ipv4_filter_num: field to update * @ipv6_filter_num: field to update * * Update filter number field for pf. **/ static void i40e_change_filter_num(bool ipv4, bool add, u16 *ipv4_filter_num, u16 *ipv6_filter_num) { … } #define I40E_UDPIP_DUMMY_PACKET_LEN … #define I40E_UDPIP6_DUMMY_PACKET_LEN … /** * i40e_add_del_fdir_udp - Add/Remove UDP filters * @vsi: pointer to the targeted VSI * @fd_data: the flow director data required for the FDir descriptor * @add: true adds a filter, false removes it * @ipv4: true is v4, false is v6 * * Returns 0 if the filters were successfully added or removed **/ static int i40e_add_del_fdir_udp(struct i40e_vsi *vsi, struct i40e_fdir_filter *fd_data, bool add, bool ipv4) { … } #define I40E_TCPIP_DUMMY_PACKET_LEN … #define I40E_TCPIP6_DUMMY_PACKET_LEN … /** * i40e_add_del_fdir_tcp - Add/Remove TCPv4 filters * @vsi: pointer to the targeted VSI * @fd_data: the flow director data required for the FDir descriptor * @add: true adds a filter, false removes it * @ipv4: true is v4, false is v6 * * Returns 0 if the filters were successfully added or removed **/ static int i40e_add_del_fdir_tcp(struct i40e_vsi *vsi, struct i40e_fdir_filter *fd_data, bool add, bool ipv4) { … } #define I40E_SCTPIP_DUMMY_PACKET_LEN … #define I40E_SCTPIP6_DUMMY_PACKET_LEN … /** * i40e_add_del_fdir_sctp - Add/Remove SCTPv4 Flow Director filters for * a specific flow spec * @vsi: pointer to the targeted VSI * @fd_data: the flow director data required for the FDir descriptor * @add: true adds a filter, false removes it * @ipv4: true is v4, false is v6 * * Returns 0 if the filters were successfully added or removed **/ static int i40e_add_del_fdir_sctp(struct i40e_vsi *vsi, struct i40e_fdir_filter *fd_data, bool add, bool ipv4) { … } #define I40E_IP_DUMMY_PACKET_LEN … #define I40E_IP6_DUMMY_PACKET_LEN … /** * i40e_add_del_fdir_ip - Add/Remove IPv4 Flow Director filters for * a specific flow spec * @vsi: pointer to the targeted VSI * @fd_data: the flow director data required for the FDir descriptor * @add: true adds a filter, false removes it * @ipv4: true is v4, false is v6 * * Returns 0 if the filters were successfully added or removed **/ static int i40e_add_del_fdir_ip(struct i40e_vsi *vsi, struct i40e_fdir_filter *fd_data, bool add, bool ipv4) { … } /** * i40e_add_del_fdir - Build raw packets to add/del fdir filter * @vsi: pointer to the targeted VSI * @input: filter to add or delete * @add: true adds a filter, false removes it * **/ int i40e_add_del_fdir(struct i40e_vsi *vsi, struct i40e_fdir_filter *input, bool add) { … } /** * i40e_fd_handle_status - check the Programming Status for FD * @rx_ring: the Rx ring for this descriptor * @qword0_raw: qword0 * @qword1: qword1 after le_to_cpu * @prog_id: the id originally used for programming * * This is used to verify if the FD programming or invalidation * requested by SW to the HW is successful or not and take actions accordingly. **/ static void i40e_fd_handle_status(struct i40e_ring *rx_ring, u64 qword0_raw, u64 qword1, u8 prog_id) { … } /** * i40e_unmap_and_free_tx_resource - Release a Tx buffer * @ring: the ring that owns the buffer * @tx_buffer: the buffer to free **/ static void i40e_unmap_and_free_tx_resource(struct i40e_ring *ring, struct i40e_tx_buffer *tx_buffer) { … } /** * i40e_clean_tx_ring - Free any empty Tx buffers * @tx_ring: ring to be cleaned **/ void i40e_clean_tx_ring(struct i40e_ring *tx_ring) { … } /** * i40e_free_tx_resources - Free Tx resources per queue * @tx_ring: Tx descriptor ring for a specific queue * * Free all transmit software resources **/ void i40e_free_tx_resources(struct i40e_ring *tx_ring) { … } /** * i40e_get_tx_pending - how many tx descriptors not processed * @ring: the ring of descriptors * @in_sw: use SW variables * * Since there is no access to the ring head register * in XL710, we need to use our local copies **/ u32 i40e_get_tx_pending(struct i40e_ring *ring, bool in_sw) { … } /** * i40e_detect_recover_hung - Function to detect and recover hung_queues * @pf: pointer to PF struct * * LAN VSI has netdev and netdev has TX queues. This function is to check * each of those TX queues if they are hung, trigger recovery by issuing * SW interrupt. **/ void i40e_detect_recover_hung(struct i40e_pf *pf) { … } /** * i40e_clean_tx_irq - Reclaim resources after transmit completes * @vsi: the VSI we care about * @tx_ring: Tx ring to clean * @napi_budget: Used to determine if we are in netpoll * @tx_cleaned: Out parameter set to the number of TXes cleaned * * Returns true if there's any budget left (e.g. the clean is finished) **/ static bool i40e_clean_tx_irq(struct i40e_vsi *vsi, struct i40e_ring *tx_ring, int napi_budget, unsigned int *tx_cleaned) { … } /** * i40e_enable_wb_on_itr - Arm hardware to do a wb, interrupts are not enabled * @vsi: the VSI we care about * @q_vector: the vector on which to enable writeback * **/ static void i40e_enable_wb_on_itr(struct i40e_vsi *vsi, struct i40e_q_vector *q_vector) { … } /** * i40e_force_wb - Issue SW Interrupt so HW does a wb * @vsi: the VSI we care about * @q_vector: the vector on which to force writeback * **/ void i40e_force_wb(struct i40e_vsi *vsi, struct i40e_q_vector *q_vector) { … } static inline bool i40e_container_is_rx(struct i40e_q_vector *q_vector, struct i40e_ring_container *rc) { … } static inline unsigned int i40e_itr_divisor(struct i40e_q_vector *q_vector) { … } /** * i40e_update_itr - update the dynamic ITR value based on statistics * @q_vector: structure containing interrupt and ring information * @rc: structure containing ring performance data * * Stores a new ITR value based on packets and byte * counts during the last interrupt. The advantage of per interrupt * computation is faster updates and more accurate ITR for the current * traffic pattern. Constants in this function were computed * based on theoretical maximum wire speed and thresholds were set based * on testing data as well as attempting to minimize response time * while increasing bulk throughput. **/ static void i40e_update_itr(struct i40e_q_vector *q_vector, struct i40e_ring_container *rc) { … } static struct i40e_rx_buffer *i40e_rx_bi(struct i40e_ring *rx_ring, u32 idx) { … } /** * i40e_reuse_rx_page - page flip buffer and store it back on the ring * @rx_ring: rx descriptor ring to store buffers on * @old_buff: donor buffer to have page reused * * Synchronizes page for reuse by the adapter **/ static void i40e_reuse_rx_page(struct i40e_ring *rx_ring, struct i40e_rx_buffer *old_buff) { … } /** * i40e_clean_programming_status - clean the programming status descriptor * @rx_ring: the rx ring that has this descriptor * @qword0_raw: qword0 * @qword1: qword1 representing status_error_len in CPU ordering * * Flow director should handle FD_FILTER_STATUS to check its filter programming * status being successful or not and take actions accordingly. FCoE should * handle its context/filter programming/invalidation status and take actions. * * Returns an i40e_rx_buffer to reuse if the cleanup occurred, otherwise NULL. **/ void i40e_clean_programming_status(struct i40e_ring *rx_ring, u64 qword0_raw, u64 qword1) { … } /** * i40e_setup_tx_descriptors - Allocate the Tx descriptors * @tx_ring: the tx ring to set up * * Return 0 on success, negative on error **/ int i40e_setup_tx_descriptors(struct i40e_ring *tx_ring) { … } static void i40e_clear_rx_bi(struct i40e_ring *rx_ring) { … } /** * i40e_clean_rx_ring - Free Rx buffers * @rx_ring: ring to be cleaned **/ void i40e_clean_rx_ring(struct i40e_ring *rx_ring) { … } /** * i40e_free_rx_resources - Free Rx resources * @rx_ring: ring to clean the resources from * * Free all receive software resources **/ void i40e_free_rx_resources(struct i40e_ring *rx_ring) { … } /** * i40e_setup_rx_descriptors - Allocate Rx descriptors * @rx_ring: Rx descriptor ring (for a specific queue) to setup * * Returns 0 on success, negative on failure **/ int i40e_setup_rx_descriptors(struct i40e_ring *rx_ring) { … } /** * i40e_release_rx_desc - Store the new tail and head values * @rx_ring: ring to bump * @val: new head index **/ void i40e_release_rx_desc(struct i40e_ring *rx_ring, u32 val) { … } #if (PAGE_SIZE >= 8192) static unsigned int i40e_rx_frame_truesize(struct i40e_ring *rx_ring, unsigned int size) { unsigned int truesize; truesize = rx_ring->rx_offset ? SKB_DATA_ALIGN(size + rx_ring->rx_offset) + SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) : SKB_DATA_ALIGN(size); return truesize; } #endif /** * i40e_alloc_mapped_page - recycle or make a new page * @rx_ring: ring to use * @bi: rx_buffer struct to modify * * Returns true if the page was successfully allocated or * reused. **/ static bool i40e_alloc_mapped_page(struct i40e_ring *rx_ring, struct i40e_rx_buffer *bi) { … } /** * i40e_alloc_rx_buffers - Replace used receive buffers * @rx_ring: ring to place buffers on * @cleaned_count: number of buffers to replace * * Returns false if all allocations were successful, true if any fail **/ bool i40e_alloc_rx_buffers(struct i40e_ring *rx_ring, u16 cleaned_count) { … } /** * i40e_rx_checksum - Indicate in skb if hw indicated a good cksum * @vsi: the VSI we care about * @skb: skb currently being received and modified * @rx_desc: the receive descriptor **/ static inline void i40e_rx_checksum(struct i40e_vsi *vsi, struct sk_buff *skb, union i40e_rx_desc *rx_desc) { … } /** * i40e_rx_hash - set the hash value in the skb * @ring: descriptor ring * @rx_desc: specific descriptor * @skb: skb currently being received and modified * @rx_ptype: Rx packet type **/ static inline void i40e_rx_hash(struct i40e_ring *ring, union i40e_rx_desc *rx_desc, struct sk_buff *skb, u8 rx_ptype) { … } /** * i40e_process_skb_fields - Populate skb header fields from Rx descriptor * @rx_ring: rx descriptor ring packet is being transacted on * @rx_desc: pointer to the EOP Rx descriptor * @skb: pointer to current skb being populated * * This function checks the ring, descriptor, and packet information in * order to populate the hash, checksum, VLAN, protocol, and * other fields within the skb. **/ void i40e_process_skb_fields(struct i40e_ring *rx_ring, union i40e_rx_desc *rx_desc, struct sk_buff *skb) { … } /** * i40e_cleanup_headers - Correct empty headers * @rx_ring: rx descriptor ring packet is being transacted on * @skb: pointer to current skb being fixed * @rx_desc: pointer to the EOP Rx descriptor * * In addition if skb is not at least 60 bytes we need to pad it so that * it is large enough to qualify as a valid Ethernet frame. * * Returns true if an error was encountered and skb was freed. **/ static bool i40e_cleanup_headers(struct i40e_ring *rx_ring, struct sk_buff *skb, union i40e_rx_desc *rx_desc) { … } /** * i40e_can_reuse_rx_page - Determine if page can be reused for another Rx * @rx_buffer: buffer containing the page * @rx_stats: rx stats structure for the rx ring * * If page is reusable, we have a green light for calling i40e_reuse_rx_page, * which will assign the current buffer to the buffer that next_to_alloc is * pointing to; otherwise, the DMA mapping needs to be destroyed and * page freed. * * rx_stats will be updated to indicate whether the page was waived * or busy if it could not be reused. */ static bool i40e_can_reuse_rx_page(struct i40e_rx_buffer *rx_buffer, struct i40e_rx_queue_stats *rx_stats) { … } /** * i40e_rx_buffer_flip - adjusted rx_buffer to point to an unused region * @rx_buffer: Rx buffer to adjust * @truesize: Size of adjustment **/ static void i40e_rx_buffer_flip(struct i40e_rx_buffer *rx_buffer, unsigned int truesize) { … } /** * i40e_get_rx_buffer - Fetch Rx buffer and synchronize data for use * @rx_ring: rx descriptor ring to transact packets on * @size: size of buffer to add to skb * * This function will pull an Rx buffer from the ring and synchronize it * for use by the CPU. */ static struct i40e_rx_buffer *i40e_get_rx_buffer(struct i40e_ring *rx_ring, const unsigned int size) { … } /** * i40e_put_rx_buffer - Clean up used buffer and either recycle or free * @rx_ring: rx descriptor ring to transact packets on * @rx_buffer: rx buffer to pull data from * * This function will clean up the contents of the rx_buffer. It will * either recycle the buffer or unmap it and free the associated resources. */ static void i40e_put_rx_buffer(struct i40e_ring *rx_ring, struct i40e_rx_buffer *rx_buffer) { … } /** * i40e_process_rx_buffs- Processing of buffers post XDP prog or on error * @rx_ring: Rx descriptor ring to transact packets on * @xdp_res: Result of the XDP program * @xdp: xdp_buff pointing to the data **/ static void i40e_process_rx_buffs(struct i40e_ring *rx_ring, int xdp_res, struct xdp_buff *xdp) { … } /** * i40e_construct_skb - Allocate skb and populate it * @rx_ring: rx descriptor ring to transact packets on * @xdp: xdp_buff pointing to the data * * This function allocates an skb. It then populates it with the page * data from the current receive descriptor, taking care to set up the * skb correctly. */ static struct sk_buff *i40e_construct_skb(struct i40e_ring *rx_ring, struct xdp_buff *xdp) { … } /** * i40e_build_skb - Build skb around an existing buffer * @rx_ring: Rx descriptor ring to transact packets on * @xdp: xdp_buff pointing to the data * * This function builds an skb around an existing Rx buffer, taking care * to set up the skb correctly and avoid any memcpy overhead. */ static struct sk_buff *i40e_build_skb(struct i40e_ring *rx_ring, struct xdp_buff *xdp) { … } /** * i40e_is_non_eop - process handling of non-EOP buffers * @rx_ring: Rx ring being processed * @rx_desc: Rx descriptor for current buffer * * If the buffer is an EOP buffer, this function exits returning false, * otherwise return true indicating that this is in fact a non-EOP buffer. */ bool i40e_is_non_eop(struct i40e_ring *rx_ring, union i40e_rx_desc *rx_desc) { … } static int i40e_xmit_xdp_ring(struct xdp_frame *xdpf, struct i40e_ring *xdp_ring); int i40e_xmit_xdp_tx_ring(struct xdp_buff *xdp, struct i40e_ring *xdp_ring) { … } /** * i40e_run_xdp - run an XDP program * @rx_ring: Rx ring being processed * @xdp: XDP buffer containing the frame * @xdp_prog: XDP program to run **/ static int i40e_run_xdp(struct i40e_ring *rx_ring, struct xdp_buff *xdp, struct bpf_prog *xdp_prog) { … } /** * i40e_xdp_ring_update_tail - Updates the XDP Tx ring tail register * @xdp_ring: XDP Tx ring * * This function updates the XDP Tx ring tail register. **/ void i40e_xdp_ring_update_tail(struct i40e_ring *xdp_ring) { … } /** * i40e_update_rx_stats - Update Rx ring statistics * @rx_ring: rx descriptor ring * @total_rx_bytes: number of bytes received * @total_rx_packets: number of packets received * * This function updates the Rx ring statistics. **/ void i40e_update_rx_stats(struct i40e_ring *rx_ring, unsigned int total_rx_bytes, unsigned int total_rx_packets) { … } /** * i40e_finalize_xdp_rx - Bump XDP Tx tail and/or flush redirect map * @rx_ring: Rx ring * @xdp_res: Result of the receive batch * * This function bumps XDP Tx tail and/or flush redirect map, and * should be called when a batch of packets has been processed in the * napi loop. **/ void i40e_finalize_xdp_rx(struct i40e_ring *rx_ring, unsigned int xdp_res) { … } /** * i40e_inc_ntp: Advance the next_to_process index * @rx_ring: Rx ring **/ static void i40e_inc_ntp(struct i40e_ring *rx_ring) { … } /** * i40e_add_xdp_frag: Add a frag to xdp_buff * @xdp: xdp_buff pointing to the data * @nr_frags: return number of buffers for the packet * @rx_buffer: rx_buffer holding data of the current frag * @size: size of data of current frag */ static int i40e_add_xdp_frag(struct xdp_buff *xdp, u32 *nr_frags, struct i40e_rx_buffer *rx_buffer, u32 size) { … } /** * i40e_consume_xdp_buff - Consume all the buffers of the packet and update ntc * @rx_ring: rx descriptor ring to transact packets on * @xdp: xdp_buff pointing to the data * @rx_buffer: rx_buffer of eop desc */ static void i40e_consume_xdp_buff(struct i40e_ring *rx_ring, struct xdp_buff *xdp, struct i40e_rx_buffer *rx_buffer) { … } /** * i40e_clean_rx_irq - Clean completed descriptors from Rx ring - bounce buf * @rx_ring: rx descriptor ring to transact packets on * @budget: Total limit on number of packets to process * @rx_cleaned: Out parameter of the number of packets processed * * This function provides a "bounce buffer" approach to Rx interrupt * processing. The advantage to this is that on systems that have * expensive overhead for IOMMU access this provides a means of avoiding * it by maintaining the mapping of the page to the system. * * Returns amount of work completed **/ static int i40e_clean_rx_irq(struct i40e_ring *rx_ring, int budget, unsigned int *rx_cleaned) { … } /** * i40e_buildreg_itr - build a value for writing to I40E_PFINT_DYN_CTLN register * @itr_idx: interrupt throttling index * @interval: interrupt throttling interval value in usecs * @force_swint: force software interrupt * * The function builds a value for I40E_PFINT_DYN_CTLN register that * is used to update interrupt throttling interval for specified ITR index * and optionally enforces a software interrupt. If the @itr_idx is equal * to I40E_ITR_NONE then no interval change is applied and only @force_swint * parameter is taken into account. If the interval change and enforced * software interrupt are not requested then the built value just enables * appropriate vector interrupt. **/ static u32 i40e_buildreg_itr(enum i40e_dyn_idx itr_idx, u16 interval, bool force_swint) { … } /* The act of updating the ITR will cause it to immediately trigger. In order * to prevent this from throwing off adaptive update statistics we defer the * update so that it can only happen so often. So after either Tx or Rx are * updated we make the adaptive scheme wait until either the ITR completely * expires via the next_update expiration or we have been through at least * 3 interrupts. */ #define ITR_COUNTDOWN_START … /** * i40e_update_enable_itr - Update itr and re-enable MSIX interrupt * @vsi: the VSI we care about * @q_vector: q_vector for which itr is being updated and interrupt enabled * **/ static inline void i40e_update_enable_itr(struct i40e_vsi *vsi, struct i40e_q_vector *q_vector) { … } /** * i40e_napi_poll - NAPI polling Rx/Tx cleanup routine * @napi: napi struct with our devices info in it * @budget: amount of work driver is allowed to do this pass, in packets * * This function will clean all queues associated with a q_vector. * * Returns the amount of work done **/ int i40e_napi_poll(struct napi_struct *napi, int budget) { … } /** * i40e_atr - Add a Flow Director ATR filter * @tx_ring: ring to add programming descriptor to * @skb: send buffer * @tx_flags: send tx flags **/ static void i40e_atr(struct i40e_ring *tx_ring, struct sk_buff *skb, u32 tx_flags) { … } /** * i40e_tx_prepare_vlan_flags - prepare generic TX VLAN tagging flags for HW * @skb: send buffer * @tx_ring: ring to send buffer on * @flags: the tx flags to be set * * Checks the skb and set up correspondingly several generic transmit flags * related to VLAN tagging for the HW, such as VLAN, DCB, etc. * * Returns error code indicate the frame should be dropped upon error and the * otherwise returns 0 to indicate the flags has been set properly. **/ static inline int i40e_tx_prepare_vlan_flags(struct sk_buff *skb, struct i40e_ring *tx_ring, u32 *flags) { … } /** * i40e_tso - set up the tso context descriptor * @first: pointer to first Tx buffer for xmit * @hdr_len: ptr to the size of the packet header * @cd_type_cmd_tso_mss: Quad Word 1 * * Returns 0 if no TSO can happen, 1 if tso is going, or error **/ static int i40e_tso(struct i40e_tx_buffer *first, u8 *hdr_len, u64 *cd_type_cmd_tso_mss) { … } /** * i40e_tsyn - set up the tsyn context descriptor * @tx_ring: ptr to the ring to send * @skb: ptr to the skb we're sending * @tx_flags: the collected send information * @cd_type_cmd_tso_mss: Quad Word 1 * * Returns 0 if no Tx timestamp can happen and 1 if the timestamp will happen **/ static int i40e_tsyn(struct i40e_ring *tx_ring, struct sk_buff *skb, u32 tx_flags, u64 *cd_type_cmd_tso_mss) { … } /** * i40e_tx_enable_csum - Enable Tx checksum offloads * @skb: send buffer * @tx_flags: pointer to Tx flags currently set * @td_cmd: Tx descriptor command bits to set * @td_offset: Tx descriptor header offsets to set * @tx_ring: Tx descriptor ring * @cd_tunneling: ptr to context desc bits **/ static int i40e_tx_enable_csum(struct sk_buff *skb, u32 *tx_flags, u32 *td_cmd, u32 *td_offset, struct i40e_ring *tx_ring, u32 *cd_tunneling) { … } /** * i40e_create_tx_ctx - Build the Tx context descriptor * @tx_ring: ring to create the descriptor on * @cd_type_cmd_tso_mss: Quad Word 1 * @cd_tunneling: Quad Word 0 - bits 0-31 * @cd_l2tag2: Quad Word 0 - bits 32-63 **/ static void i40e_create_tx_ctx(struct i40e_ring *tx_ring, const u64 cd_type_cmd_tso_mss, const u32 cd_tunneling, const u32 cd_l2tag2) { … } /** * __i40e_maybe_stop_tx - 2nd level check for tx stop conditions * @tx_ring: the ring to be checked * @size: the size buffer we want to assure is available * * Returns -EBUSY if a stop is needed, else 0 **/ int __i40e_maybe_stop_tx(struct i40e_ring *tx_ring, int size) { … } /** * __i40e_chk_linearize - Check if there are more than 8 buffers per packet * @skb: send buffer * * Note: Our HW can't DMA more than 8 buffers to build a packet on the wire * and so we need to figure out the cases where we need to linearize the skb. * * For TSO we need to count the TSO header and segment payload separately. * As such we need to check cases where we have 7 fragments or more as we * can potentially require 9 DMA transactions, 1 for the TSO header, 1 for * the segment payload in the first descriptor, and another 7 for the * fragments. **/ bool __i40e_chk_linearize(struct sk_buff *skb) { … } /** * i40e_tx_map - Build the Tx descriptor * @tx_ring: ring to send buffer on * @skb: send buffer * @first: first buffer info buffer to use * @tx_flags: collected send information * @hdr_len: size of the packet header * @td_cmd: the command field in the descriptor * @td_offset: offset for checksum or crc * * Returns 0 on success, -1 on failure to DMA **/ static inline int i40e_tx_map(struct i40e_ring *tx_ring, struct sk_buff *skb, struct i40e_tx_buffer *first, u32 tx_flags, const u8 hdr_len, u32 td_cmd, u32 td_offset) { … } static u16 i40e_swdcb_skb_tx_hash(struct net_device *dev, const struct sk_buff *skb, u16 num_tx_queues) { … } u16 i40e_lan_select_queue(struct net_device *netdev, struct sk_buff *skb, struct net_device __always_unused *sb_dev) { … } /** * i40e_xmit_xdp_ring - transmits an XDP buffer to an XDP Tx ring * @xdpf: data to transmit * @xdp_ring: XDP Tx ring **/ static int i40e_xmit_xdp_ring(struct xdp_frame *xdpf, struct i40e_ring *xdp_ring) { … } /** * i40e_xmit_frame_ring - Sends buffer on Tx ring * @skb: send buffer * @tx_ring: ring to send buffer on * * Returns NETDEV_TX_OK if sent, else an error code **/ static netdev_tx_t i40e_xmit_frame_ring(struct sk_buff *skb, struct i40e_ring *tx_ring) { … } /** * i40e_lan_xmit_frame - Selects the correct VSI and Tx queue to send buffer * @skb: send buffer * @netdev: network interface device structure * * Returns NETDEV_TX_OK if sent, else an error code **/ netdev_tx_t i40e_lan_xmit_frame(struct sk_buff *skb, struct net_device *netdev) { … } /** * i40e_xdp_xmit - Implements ndo_xdp_xmit * @dev: netdev * @n: number of frames * @frames: array of XDP buffer pointers * @flags: XDP extra info * * Returns number of frames successfully sent. Failed frames * will be free'ed by XDP core. * * For error cases, a negative errno code is returned and no-frames * are transmitted (caller must handle freeing frames). **/ int i40e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames, u32 flags) { … }