ice: Introduce ice_base.c
Subsystems (2)
Tony Nguyen
maintainerPATCH v3 1/9 ice: Introduce ice_base.c
From: Anirudh Venkataramanan <[email protected]>
Remove a few uses of kernel configuration flags from ice_lib.c by introducing a new source file ice_base.c. Also move corresponding function prototypes from ice_lib.h to ice_base.h and include ice_base.h where required.
--- drivers/net/ethernet/intel/ice/Makefile | 1 + drivers/net/ethernet/intel/ice/ice.h | 8 + drivers/net/ethernet/intel/ice/ice_base.c | 767 +++++++++++++++++ drivers/net/ethernet/intel/ice/ice_base.h | 31 + drivers/net/ethernet/intel/ice/ice_dcb_lib.h | 1 + drivers/net/ethernet/intel/ice/ice_lib.c | 787 +----------------- drivers/net/ethernet/intel/ice/ice_lib.h | 39 - drivers/net/ethernet/intel/ice/ice_main.c | 1 + drivers/net/ethernet/intel/ice/ice_txrx.h | 2 - .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 1 + 10 files changed, 811 insertions(+), 827 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_base.c create mode 100644 drivers/net/ethernet/intel/ice/ice_base.h
drivers/net/ethernet/intel/ice/Makefile +1 -0
@@ -13,6 +13,7 @@ ice-y := ice_main.o \ ice_nvm.o \ ice_switch.o \ ice_sched.o \ + ice_base.o \ ice_lib.o \ ice_txrx.o \ ice_flex_pipe.o \
drivers/net/ethernet/intel/ice/ice.h +8 -0
@@ -130,6 +130,14 @@ extern const char ice_drv_ver[]; ICE_PROMISC_VLAN_TX | \ ICE_PROMISC_VLAN_RX) +struct ice_txq_meta { +u32 q_teid;/* Tx-scheduler element identifier */ +u16 q_id;/* Entry in VSI's txq_map bitmap */ +u16 q_handle;/* Relative index of Tx queue within TC */ +u16 vsi_idx;/* VSI index that Tx queue belongs to */ +u8 tc;/* TC number that Tx queue belongs to */ +}; +struct ice_tc_info {u16 qoffset;u16 qcount_tx;
drivers/net/ethernet/intel/ice/ice_base.c new file +767 -0
767 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_base.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2019, Intel Corporation. */ + +#ifndef _ICE_BASE_H_ +#define _ICE_BASE_H_ + +#include "ice.h" + +int ice_setup_rx_ctx (struct ice_ring *ring); +int __ice_vsi_get_qs (struct ice_qs_cfg *qs_cfg); +int ice_vsi_ctrl_rx_ring (struct ice_vsi *vsi,bool ena,u16 rxq_idx); +int ice_vsi_alloc_q_vectors (struct ice_vsi *vsi); +void ice_vsi_map_rings_to_vectors (struct ice_vsi *vsi); +void ice_vsi_free_q_vectors (struct ice_vsi *vsi); +int +ice_vsi_cfg_txq (struct ice_vsi *vsi,struct ice_ring *ring,u16 tc_q_idx, +struct ice_aqc_add_tx_qgrp *qg_buf,u8 tc); +void ice_cfg_itr (struct ice_hw *hw,struct ice_q_vector *q_vector); +void +ice_cfg_txq_interrupt (struct ice_vsi *vsi,u16 txq,u16 msix_idx,u16 itr_idx); +void +ice_cfg_rxq_interrupt (struct ice_vsi *vsi,u16 rxq,u16 msix_idx,u16 itr_idx); +void ice_trigger_sw_intr (struct ice_hw *hw,struct ice_q_vector *q_vector); +int +ice_vsi_stop_tx_ring (struct ice_vsi *vsi,enum ice_disq_rst_src rst_src, +u16 rel_vmvf_num,struct ice_ring *ring, +struct ice_txq_meta *txq_meta); +void +ice_fill_txq_meta (struct ice_vsi *vsi,struct ice_ring *ring, +struct ice_txq_meta *txq_meta); +#endif /* _ICE_BASE_H_ */
drivers/net/ethernet/intel/ice/ice_dcb_lib.h +1 -0
@@ -5,6 +5,7 @@#define _ICE_DCB_LIB_H_#include "ice.h" +#include "ice_base.h" #include "ice_lib.h" #ifdef CONFIG_DCB
drivers/net/ethernet/intel/ice/ice_lib.c +1 -786
844 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_lib.h +0 -39
@@ -6,19 +6,6 @@#include "ice.h" -struct ice_txq_meta { -/* Tx-scheduler element identifier */ -u32 q_teid; -/* Entry in VSI's txq_map bitmap */ -u16 q_id; -/* Relative index of Tx queue within TC */ -u16 q_handle; -/* VSI index that Tx queue belongs to */ -u16 vsi_idx; -/* TC number that Tx queue belongs to */ -u8 tc; -}; -int ice_add_mac_to_list (struct ice_vsi *vsi,struct list_head *add_list,const u8 *macaddr);
@@ -35,24 +22,6 @@ int ice_vsi_cfg_lan_txqs(struct ice_vsi *vsi);void ice_vsi_cfg_msix (struct ice_vsi *vsi); -#ifdef CONFIG_PCI_IOV -void -ice_cfg_txq_interrupt (struct ice_vsi *vsi,u16 txq,u16 msix_idx,u16 itr_idx); - -void -ice_cfg_rxq_interrupt (struct ice_vsi *vsi,u16 rxq,u16 msix_idx,u16 itr_idx); - -int -ice_vsi_stop_tx_ring (struct ice_vsi *vsi,enum ice_disq_rst_src rst_src, -u16 rel_vmvf_num,struct ice_ring *ring, -struct ice_txq_meta *txq_meta); - -void ice_fill_txq_meta (struct ice_vsi *vsi,struct ice_ring *ring, -struct ice_txq_meta *txq_meta); - -int ice_vsi_ctrl_rx_ring (struct ice_vsi *vsi,bool ena,u16 rxq_idx); -#endif /* CONFIG_PCI_IOV */ -int ice_vsi_add_vlan (struct ice_vsi *vsi,u16 vid);int ice_vsi_kill_vlan (struct ice_vsi *vsi,u16 vid);
@@ -100,16 +69,8 @@ int ice_vsi_rebuild(struct ice_vsi *vsi);bool ice_is_reset_in_progress (unsigned long *state); -void ice_vsi_free_q_vectors (struct ice_vsi *vsi); - -void ice_trigger_sw_intr (struct ice_hw *hw,struct ice_q_vector *q_vector); -void ice_vsi_put_qs (struct ice_vsi *vsi); -#ifdef CONFIG_DCB -void ice_vsi_map_rings_to_vectors (struct ice_vsi *vsi); -#endif /* CONFIG_DCB */ -void ice_vsi_dis_irq (struct ice_vsi *vsi);void ice_vsi_free_irq (struct ice_vsi *vsi);
drivers/net/ethernet/intel/ice/ice_main.c +1 -0
@@ -6,6 +6,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include "ice.h" +#include "ice_base.h" #include "ice_lib.h" #include "ice_dcb_lib.h"
drivers/net/ethernet/intel/ice/ice_txrx.h +0 -2
@@ -205,9 +205,7 @@ struct ice_ring {unsigned int size;/* length of descriptor ring in bytes */ u32 txq_teid;/* Added Tx queue TEID */ u16 rx_buf_len; -#ifdef CONFIG_DCB u8 dcb_tc;/* Traffic class of ring */ -#endif /* CONFIG_DCB */ }____cacheline_internodealigned_in_smp ;struct ice_ring_container {
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +1 -0
@@ -2,6 +2,7 @@/* Copyright (c) 2018, Intel Corporation. */ #include "ice.h" +#include "ice_base.h" #include "ice_lib.h" /**
Signature · 1 line
2.20.1
Tony Nguyen
maintainerPATCH v3 2/9 ice: get rid of per-tc flow in Tx queue configuration routines
From: Maciej Fijalkowski <[email protected]>
There's no reason for treating DCB as first class citizen when configuring the Tx queues and going through TCs. Reverse the logic and base the configuration logic on rings, which is the object of interest anyway.
--- drivers/net/ethernet/intel/ice/ice_base.c | 29 +++++++++-- drivers/net/ethernet/intel/ice/ice_base.h | 4 +- drivers/net/ethernet/intel/ice/ice_lib.c | 63 ++++++++--------------- 3 files changed, 47 insertions(+), 49 deletions(-)
drivers/net/ethernet/intel/ice/ice_base.c +24 -5
@@ -190,6 +190,21 @@ static void ice_cfg_itr_gran(struct ice_hw *hw)wr32 (hw,GLINT_CTL , regval); } +/** +* ice_calc_q_handle - calculate the queue handle +* @vsi: VSI that ring belongs to +* @ring: ring to get the absolute queue index +* @tc: traffic class number +*/ +static u16 ice_calc_q_handle (struct ice_vsi *vsi,struct ice_ring *ring,u8 tc) +{ +/* idea here for calculation is that we subtract the number of queue +* count from TC that ring belongs to from it's absolute queue index +* and as a result we get the queue's index within TC. +*/ +return ring->q_index - vsi->tc_cfg.tc_info[tc].qoffset; +} +/** * ice_setup_tx_ctx - setup a struct ice_tlan_ctx instance * @ring: The Tx ring to configure
@@ -522,13 +537,11 @@ void ice_vsi_free_q_vectors(struct ice_vsi *vsi)* ice_vsi_cfg_txq - Configure single Tx queue * @vsi: the VSI that queue belongs to * @ring: Tx ring to be configured -* @tc_q_idx: queue index within given TC * @qg_buf: queue group buffer -* @tc: TC that Tx ring belongs to */ int -ice_vsi_cfg_txq (struct ice_vsi *vsi,struct ice_ring *ring,u16 tc_q_idx, -struct ice_aqc_add_tx_qgrp *qg_buf,u8 tc) +ice_vsi_cfg_txq (struct ice_vsi *vsi,struct ice_ring *ring, +struct ice_aqc_add_tx_qgrp *qg_buf) {struct ice_tlan_ctx tlan_ctx = {0 };struct ice_aqc_add_txqs_perq *txq;
@@ -536,6 +549,7 @@ ice_vsi_cfg_txq(struct ice_vsi *vsi, struct ice_ring *ring, u16 tc_q_idx,u8 buf_len =sizeof (*qg_buf);enum ice_status status;u16 pf_q; +u8 tc; pf_q = ring->reg_idx;ice_setup_tx_ctx (ring, &tlan_ctx, pf_q);
@@ -549,10 +563,15 @@ ice_vsi_cfg_txq(struct ice_vsi *vsi, struct ice_ring *ring, u16 tc_q_idx,*/ ring->tail = pf->hw.hw_addr +QTX_COMM_DBELL (pf_q); +if (IS_ENABLED (CONFIG_DCB )) + tc = ring->dcb_tc; +else + tc =0 ; +/* Add unique software queue handle of the Tx queue per * TC into the VSI Tx ring */ - ring->q_handle = tc_q_idx; + ring->q_handle =ice_calc_q_handle (vsi, ring, tc); status =ice_ena_vsi_txq (vsi->port_info, vsi->idx, tc, ring->q_handle,1 , qg_buf, buf_len,NULL );
drivers/net/ethernet/intel/ice/ice_base.h +2 -2
@@ -13,8 +13,8 @@ int ice_vsi_alloc_q_vectors(struct ice_vsi *vsi);void ice_vsi_map_rings_to_vectors (struct ice_vsi *vsi);void ice_vsi_free_q_vectors (struct ice_vsi *vsi);int -ice_vsi_cfg_txq (struct ice_vsi *vsi,struct ice_ring *ring,u16 tc_q_idx, -struct ice_aqc_add_tx_qgrp *qg_buf,u8 tc); +ice_vsi_cfg_txq (struct ice_vsi *vsi,struct ice_ring *ring, +struct ice_aqc_add_tx_qgrp *qg_buf);void ice_cfg_itr (struct ice_hw *hw,struct ice_q_vector *q_vector);void ice_cfg_txq_interrupt (struct ice_vsi *vsi,u16 txq,u16 msix_idx,u16 itr_idx);
drivers/net/ethernet/intel/ice/ice_lib.c +21 -42
104 lines not on this page · raw message
Signature · 1 line
2.20.1
Bowers
PATCH v3 2/9 ice: get rid of per-tc flow in Tx queue configuration routines
Quoted 14 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Thursday, October 24, 2019 1:11 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S30 v3 2/9] ice: get rid of per-tc flow in Tx queue configuration routinesFrom: Maciej Fijalkowski <[email protected]>
There's no reason for treating DCB as first class citizen when configuring the Tx queues and going through TCs. Reverse the logic and base the configuration logic on rings, which is the object of interest anyway.
Quoted 7 lines
Signed-off-by Maciej Fijalkowski <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/ice/ice_base.c | 29 +++++++++-- drivers/net/ethernet/intel/ice/ice_base.h | 4 +- drivers/net/ethernet/intel/ice/ice_lib.c | 63 ++++++++--------------- 3 files changed, 47 insertions(+), 49 deletions(-)
Tony Nguyen
maintainerPATCH v3 3/9 ice: Add support for XDP
In reply to Tony NguyenFrom: Maciej Fijalkowski <[email protected]>
Add support for XDP. Implement ndo_bpf and ndo_xdp_xmit. Upon load of an XDP program, allocate additional Tx rings for dedicated XDP use. The following actions are supported: XDP_TX, XDP_DROP, XDP_REDIRECT, XDP_PASS, and XDP_ABORTED.
--- drivers/net/ethernet/intel/ice/ice.h | 24 +- drivers/net/ethernet/intel/ice/ice_base.c | 28 +- drivers/net/ethernet/intel/ice/ice_ethtool.c | 50 ++- drivers/net/ethernet/intel/ice/ice_lib.c | 69 +++- drivers/net/ethernet/intel/ice/ice_lib.h | 6 + drivers/net/ethernet/intel/ice/ice_main.c | 319 +++++++++++++++++ drivers/net/ethernet/intel/ice/ice_txrx.c | 351 ++++++++++++++++--- drivers/net/ethernet/intel/ice/ice_txrx.h | 34 +- 8 files changed, 822 insertions(+), 59 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +22 -2
@@ -29,8 +29,10 @@#include <linux/ip.h> #include <linux/sctp.h> #include <linux/ipv6.h> +#include <linux/pkt_sched.h> #include <linux/if_bridge.h> #include <linux/ctype.h> +#include <linux/bpf.h> #include <linux/avf/virtchnl.h> #include <linux/mfd/core.h> #include <net/ipv6.h>
@@ -81,8 +83,7 @@ extern const char ice_drv_ver[];#define ICE_DFLT_NETIF_M (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK) -#define ICE_MAX_MTU (ICE_AQ_SET_MAC_FRAME_SIZE_MAX - \ - (ETH_HLEN + ETH_FCS_LEN + (VLAN_HLEN * 2))) +#define ICE_MAX_MTU (ICE_AQ_SET_MAC_FRAME_SIZE_MAX - ICE_ETH_PKT_HDR_PAD)#define ICE_UP_TABLE_TRANSLATE (val, i) \ (((val) << ICE_AQ_VSI_UP_TABLE_UP##i##_S) & \
@@ -286,6 +287,10 @@ struct ice_vsi {u16 num_tx_desc;u16 qset_handle[ICE_MAX_TRAFFIC_CLASS ];struct ice_tc_cfg tc_cfg; +struct bpf_prog *xdp_prog; +struct ice_ring **xdp_rings;/* XDP ring array */ +u16 num_xdp_txq;/* Used XDP queues */ +u8 xdp_mapping_mode;/* ICE_MAP_MODE_[CONTIG|SCATTER] */ }____cacheline_internodealigned_in_smp ;/* struct that defines an interrupt vector */
@@ -438,6 +443,16 @@ static inline struct ice_pf *ice_netdev_to_pf(struct net_device *netdev)return np->vsi->back; } +static inline bool ice_is_xdp_ena_vsi (struct ice_vsi *vsi) +{ +return !!vsi->xdp_prog; +} + +static inline void ice_set_ring_xdp (struct ice_ring *ring) +{ + ring->flags |=ICE_TX_FLAGS_RING_XDP ; +} +/** * ice_get_main_vsi - Get the PF VSI * @pf: PF instance
@@ -464,6 +479,11 @@ int ice_up(struct ice_vsi *vsi);int ice_down (struct ice_vsi *vsi);int ice_vsi_cfg (struct ice_vsi *vsi);struct ice_vsi *ice_lb_vsi_setup (struct ice_pf *pf,struct ice_port_info *pi); +int ice_prepare_xdp_rings (struct ice_vsi *vsi); +int ice_destroy_xdp_rings (struct ice_vsi *vsi); +int +ice_xdp_xmit (struct net_device *dev,int n,struct xdp_frame **frames, +u32 flags);int ice_set_rss (struct ice_vsi *vsi,u8 *seed,u8 *lut,u16 lut_size);int ice_get_rss (struct ice_vsi *vsi,u8 *seed,u8 *lut,u16 lut_size);void ice_fill_rss_lut (u8 *lut,u16 rss_table_size,u16 rss_size);
drivers/net/ethernet/intel/ice/ice_base.c +27 -1
@@ -198,6 +198,9 @@ static void ice_cfg_itr_gran(struct ice_hw *hw)*/ static u16 ice_calc_q_handle (struct ice_vsi *vsi,struct ice_ring *ring,u8 tc) { +WARN_ONCE (ice_ring_is_xdp (ring) && tc, +"XDP ring can't belong to TC other than 0" ); +/* idea here for calculation is that we subtract the number of queue * count from TC that ring belongs to from it's absolute queue index * and as a result we get the queue's index within TC.
@@ -287,6 +290,22 @@ int ice_setup_rx_ctx(struct ice_ring *ring)/* clear the context structure first */ memset (&rlan_ctx,0 ,sizeof (rlan_ctx)); + ring->rx_buf_len = vsi->rx_buf_len; + +if (ring->vsi->type ==ICE_VSI_PF ) { +if (!xdp_rxq_info_is_reg (&ring->xdp_rxq)) +xdp_rxq_info_reg (&ring->xdp_rxq, ring->netdev, + ring->q_index); + + err =xdp_rxq_info_reg_mem_model (&ring->xdp_rxq, +MEM_TYPE_PAGE_SHARED ,NULL ); +if (err) +return err; + } +/* Receive Queue Base Address. +* Indicates the starting address of the descriptor queue defined in +* 128 Byte units. +*/ rlan_ctx.base = ring->dma >>7 ; rlan_ctx.qlen = ring->count;
@@ -294,7 +313,7 @@ int ice_setup_rx_ctx(struct ice_ring *ring)/* Receive Packet Data Buffer Size. * The Packet Data Buffer Size is defined in 128 byte units. */ - rlan_ctx.dbuf = vsi->rx_buf_len >>ICE_RLAN_CTX_DBUF_S ; + rlan_ctx.dbuf = ring->rx_buf_len >>ICE_RLAN_CTX_DBUF_S ;/* use 32 byte descriptors */ rlan_ctx.dsize =1 ;
@@ -657,6 +676,13 @@ ice_cfg_txq_interrupt(struct ice_vsi *vsi, u16 txq, u16 msix_idx, u16 itr_idx) ((msix_idx <<QINT_TQCTL_MSIX_INDX_S ) &QINT_TQCTL_MSIX_INDX_M );wr32 (hw,QINT_TQCTL (vsi->txq_map[txq]), val); +if (ice_is_xdp_ena_vsi (vsi)) { +u32 xdp_txq = txq + vsi->num_xdp_txq; + +wr32 (hw,QINT_TQCTL (vsi->txq_map[xdp_txq]), + val); + } +ice_flush (hw); }/**
drivers/net/ethernet/intel/ice/ice_ethtool.c +47 -3
80 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_lib.c +60 -9
125 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_lib.h +6 -0
@@ -38,6 +38,10 @@ int ice_vsi_stop_lan_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src, u16 rel_vmvf_num); +int ice_vsi_cfg_xdp_txqs (struct ice_vsi *vsi); + +int ice_vsi_stop_xdp_tx_rings (struct ice_vsi *vsi); +int ice_cfg_vlan_pruning (struct ice_vsi *vsi,bool ena,bool vlan_promisc);void ice_cfg_sw_lldp (struct ice_vsi *vsi,bool tx,bool create);
@@ -81,6 +85,8 @@ void ice_vsi_free_tx_rings(struct ice_vsi *vsi);int ice_vsi_manage_rss_lut (struct ice_vsi *vsi,bool ena); +void ice_vsi_cfg_frame_size (struct ice_vsi *vsi); +u32 ice_intrl_usec_to_reg (u8 intrl,u8 gran);char *ice_nvm_version_str (struct ice_hw *hw);
drivers/net/ethernet/intel/ice/ice_main.c +319 -0
353 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_txrx.c +308 -43
499 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_txrx.h +33 -1
@@ -22,6 +22,16 @@#define ICE_RX_BUF_WRITE 16/* Must be power of 2 */ #define ICE_MAX_TXQ_PER_TXQG 128 +static inline __le64 +ice_build_ctob (u64 td_cmd,u64 td_offset,unsigned int size,u64 td_tag) +{ +return cpu_to_le64 (ICE_TX_DESC_DTYPE_DATA | + (td_cmd <<ICE_TXD_QW1_CMD_S ) | + (td_offset <<ICE_TXD_QW1_OFFSET_S ) | + ((u64 )size <<ICE_TXD_QW1_TX_BUF_SZ_S ) | + (td_tag <<ICE_TXD_QW1_L2TAG1_S )); +} +/* We are assuming that the cache line is always 64 Bytes here for ice. * In order to make sure that is a correct assumption there is a check in probe * to print a warning if the read from GLPCI_CNF2 tells us that the cache line
@@ -49,12 +59,24 @@#define ICE_TX_FLAGS_VLAN_PR_S 29#define ICE_TX_FLAGS_VLAN_S 16 +#define ICE_XDP_PASS 0 +#define ICE_XDP_CONSUMED BIT(0) +#define ICE_XDP_TX BIT(1) +#define ICE_XDP_REDIR BIT(2) +#define ICE_RX_DMA_ATTR \ (DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_WEAK_ORDERING) +#define ICE_ETH_PKT_HDR_PAD (ETH_HLEN + ETH_FCS_LEN + (VLAN_HLEN * 2)) + +#define ICE_TXD_LAST_DESC_CMD (ICE_TX_DESC_CMD_EOP | ICE_TX_DESC_CMD_RS) +struct ice_tx_buf {struct ice_tx_desc *next_to_watch; -struct sk_buff *skb; +union { +struct sk_buff *skb; +void *raw_buf;/* used for XDP */ + };unsigned int bytecount;unsigned short gso_segs;u32 tx_flags;
@@ -198,9 +220,14 @@ struct ice_ring { };struct rcu_head rcu;/* to avoid race on free */ +struct bpf_prog *xdp_prog; +/* CL3 - 3rd cacheline starts here */ +struct xdp_rxq_info xdp_rxq;/* CLX - the below items are only accessed infrequently and should be * in their own cache line if possible */ +#define ICE_TX_FLAGS_RING_XDP BIT(0) +u8 flags;dma_addr_t dma;/* physical address of ring */ unsigned int size;/* length of descriptor ring in bytes */ u32 txq_teid;/* Added Tx queue TEID */
@@ -208,6 +235,11 @@ struct ice_ring {u8 dcb_tc;/* Traffic class of ring */ }____cacheline_internodealigned_in_smp ; +static inline bool ice_ring_is_xdp (struct ice_ring *ring) +{ +return !!(ring->flags &ICE_TX_FLAGS_RING_XDP ); +} +struct ice_ring_container {/* head of linked-list of rings */ struct ice_ring *ring;
Signature · 1 line
2.20.1
Bowers
PATCH v3 3/9 ice: Add support for XDP
Quoted 16 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Thursday, October 24, 2019 1:11 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S30 v3 3/9] ice: Add support for XDPFrom: Maciej Fijalkowski <[email protected]>
Add support for XDP. Implement
ndo_bpfandndo_xdp_xmit. Upon load of an XDP program, allocate additional Tx rings for dedicated XDP use. The following actions are supported:XDP_TX,XDP_DROP,XDP_REDIRECT,XDP_PASS, andXDP_ABORTED.Signed-off-by Maciej Fijalkowski <[email protected]>Signed-off-by Tony Nguyen <[email protected]>
Quoted 10 lines
--- drivers/net/ethernet/intel/ice/ice.h | 24 +- drivers/net/ethernet/intel/ice/ice_base.c | 28 +- drivers/net/ethernet/intel/ice/ice_ethtool.c | 50 ++- drivers/net/ethernet/intel/ice/ice_lib.c | 69 +++- drivers/net/ethernet/intel/ice/ice_lib.h | 6 + drivers/net/ethernet/intel/ice/ice_main.c | 319 +++++++++++++++++ drivers/net/ethernet/intel/ice/ice_txrx.c | 351 ++++++++++++++++--- drivers/net/ethernet/intel/ice/ice_txrx.h | 34 +- 8 files changed, 822 insertions(+), 59 deletions(-)
Tony Nguyen
maintainerPATCH v3 4/9 ice: Move common functions to ice_txrx_lib.c
In reply to Tony NguyenFrom: Krzysztof Kazimierczak <[email protected]>
In preparation of AF XDP, move functions that will be used both by skb and zero-copy paths to a new file called ice_txrx_lib.c. This allows us to avoid using ifdefs to control the staticness of said functions.
Move other functions (ice_rx_csum, ice_rx_hash and ice_ptype_to_htype) called only by the moved ones to the new file as well.
---
v2:
- Move ice_build_ctob() to ice_txrx_lib.h
--- drivers/net/ethernet/intel/ice/Makefile | 1 + drivers/net/ethernet/intel/ice/ice_txrx.c | 303 +----------------- drivers/net/ethernet/intel/ice/ice_txrx.h | 10 - drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 273 ++++++++++++++++ drivers/net/ethernet/intel/ice/ice_txrx_lib.h | 59 ++++ 5 files changed, 334 insertions(+), 312 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_txrx_lib.c create mode 100644 drivers/net/ethernet/intel/ice/ice_txrx_lib.h
drivers/net/ethernet/intel/ice/Makefile +1 -0
@@ -15,6 +15,7 @@ ice-y := ice_main.o \ ice_sched.o \ ice_base.o \ ice_lib.o \ + ice_txrx_lib.o \ ice_txrx.o \ ice_flex_pipe.o \ ice_idc.o \
drivers/net/ethernet/intel/ice/ice_txrx.c +1 -302
339 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_txrx.h +0 -10
@@ -22,16 +22,6 @@#define ICE_RX_BUF_WRITE 16/* Must be power of 2 */ #define ICE_MAX_TXQ_PER_TXQG 128 -static inline __le64 -ice_build_ctob (u64 td_cmd,u64 td_offset,unsigned int size,u64 td_tag) -{ -return cpu_to_le64 (ICE_TX_DESC_DTYPE_DATA | - (td_cmd <<ICE_TXD_QW1_CMD_S ) | - (td_offset <<ICE_TXD_QW1_OFFSET_S ) | - ((u64 )size <<ICE_TXD_QW1_TX_BUF_SZ_S ) | - (td_tag <<ICE_TXD_QW1_L2TAG1_S )); -} -/* We are assuming that the cache line is always 64 Bytes here for ice. * In order to make sure that is a correct assumption there is a check in probe * to print a warning if the read from GLPCI_CNF2 tells us that the cache line
drivers/net/ethernet/intel/ice/ice_txrx_lib.c new file +273 -0
273 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_txrx_lib.h new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
2.20.1
Bowers
PATCH v3 4/9 ice: Move common functions to ice_txrx_lib.c
Quoted 22 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Thursday, October 24, 2019 1:11 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S30 v3 4/9] ice: Move common functions toice_txrx_lib.cFrom: Krzysztof Kazimierczak <[email protected]>
In preparation of AF XDP, move functions that will be used both by skb and zero-copy paths to a new file called
ice_txrx_lib.c. This allows us to avoid using ifdefs to control the staticness of said functions.Move other functions (
ice_rx_csum,ice_rx_hashandice_ptype_to_htype) called only by the moved ones to the new file as well.Signed-off-by Krzysztof Kazimierczak <[email protected]>Signed-off-by Tony Nguyen <[email protected]>---
v2:
- Moveice_build_ctob()toice_txrx_lib.h
Quoted 9 lines
--- drivers/net/ethernet/intel/ice/Makefile | 1 + drivers/net/ethernet/intel/ice/ice_txrx.c | 303 +----------------- drivers/net/ethernet/intel/ice/ice_txrx.h | 10 - drivers/net/ethernet/intel/ice/ice_txrx_lib.c | 273 ++++++++++++++++ drivers/net/ethernet/intel/ice/ice_txrx_lib.h | 59 ++++ 5 files changed, 334 insertions(+), 312 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_txrx_lib.c create mode 100644 drivers/net/ethernet/intel/ice/ice_txrx_lib.h
Tony Nguyen
maintainerPATCH v3 5/9 ice: Add support for AF_XDP
In reply to Tony NguyenFrom: Krzysztof Kazimierczak <[email protected]>
Add zero copy AF_XDP support. This patch adds zero copy support for Tx and Rx; code for zero copy is added to ice_xsk.h and ice_xsk.c.
For Tx, implement ndo_xsk_wakeup. As with other drivers, reuse existing XDP Tx queues for this task, since XDP_REDIRECT guarantees mutual exclusion between different NAPI contexts based on CPU ID. In turn, a netdev can XDP_REDIRECT to another netdev with a different NAPI context, since the operation is bound to a specific core and each core has its own hardware ring.
For Rx, allocate frames as MEM_TYPE_ZERO_COPY on queues that AF_XDP is enabled.
---
v3:
- Remove unused prototype ice_xsk_umem_query()
--- drivers/net/ethernet/intel/ice/Makefile | 1 + drivers/net/ethernet/intel/ice/ice.h | 26 + drivers/net/ethernet/intel/ice/ice_base.c | 53 +- drivers/net/ethernet/intel/ice/ice_ethtool.c | 7 + drivers/net/ethernet/intel/ice/ice_lib.c | 57 +- drivers/net/ethernet/intel/ice/ice_lib.h | 4 + drivers/net/ethernet/intel/ice/ice_main.c | 13 + drivers/net/ethernet/intel/ice/ice_txrx.c | 46 +- drivers/net/ethernet/intel/ice/ice_txrx.h | 20 +- drivers/net/ethernet/intel/ice/ice_xsk.c | 1181 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_xsk.h | 72 ++ 11 files changed, 1453 insertions(+), 27 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_xsk.c create mode 100644 drivers/net/ethernet/intel/ice/ice_xsk.h
drivers/net/ethernet/intel/ice/Makefile +1 -0
@@ -22,3 +22,4 @@ ice-y := ice_main.o \ ice_ethtool.o ice-$(CONFIG_PCI_IOV) += ice_virtchnl_pf.o ice_sriov.o ice-$(CONFIG_DCB) += ice_dcb.o ice_dcb_lib.o +ice-$(CONFIG_XDP_SOCKETS) += ice_xsk.o
drivers/net/ethernet/intel/ice/ice.h +26 -0
@@ -36,6 +36,7 @@#include <linux/avf/virtchnl.h> #include <linux/mfd/core.h> #include <net/ipv6.h> +#include <net/xdp_sock.h> #include "ice_devids.h" #include "ice_type.h" #include "ice_txrx.h"
@@ -46,6 +47,7 @@#include "ice_idc_int.h" #include "ice_virtchnl_pf.h" #include "ice_sriov.h" +#include "ice_xsk.h" extern const char ice_drv_ver[];#define ICE_BAR0 0
@@ -291,6 +293,9 @@ struct ice_vsi {struct ice_ring **xdp_rings;/* XDP ring array */ u16 num_xdp_txq;/* Used XDP queues */ u8 xdp_mapping_mode;/* ICE_MAP_MODE_[CONTIG|SCATTER] */ +struct xdp_umem **xsk_umems; +u16 num_xsk_umems_used; +u16 num_xsk_umems; }____cacheline_internodealigned_in_smp ;/* struct that defines an interrupt vector */
@@ -453,6 +458,27 @@ static inline void ice_set_ring_xdp(struct ice_ring *ring) ring->flags |=ICE_TX_FLAGS_RING_XDP ; } +/** +* ice_xsk_umem - get XDP UMEM bound to a ring +* @ring - ring to use +* +* Returns a pointer to xdp_umem structure if there is an UMEM present, +* NULL otherwise. +*/ +static inline struct xdp_umem *ice_xsk_umem (struct ice_ring *ring) +{ +struct xdp_umem **umems = ring->vsi->xsk_umems; +int qid = ring->q_index; + +if (ice_ring_is_xdp (ring)) + qid -= ring->vsi->num_xdp_txq; + +if (!umems || !umems[qid] || !ice_is_xdp_ena_vsi (ring->vsi)) +return NULL ; + +return umems[qid]; +} +/** * ice_get_main_vsi - Get the PF VSI * @pf: PF instance
drivers/net/ethernet/intel/ice/ice_base.c +46 -7
84 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_ethtool.c +7 -0
@@ -2612,6 +2612,13 @@ ice_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)return 0 ; } +/* If there is a AF_XDP UMEM attached to any of Rx rings, +* disallow changing the number of descriptors -- regardless +* if the netdev is running or not. +*/ +if (ice_xsk_any_rx_ring_ena (vsi)) +return -EBUSY ; +while (test_and_set_bit (__ICE_CFG_BUSY, pf->state)) { timeout--;if (!timeout)
drivers/net/ethernet/intel/ice/ice_lib.c +56 -1
69 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_lib.h +4 -0
@@ -85,6 +85,10 @@ void ice_vsi_free_tx_rings(struct ice_vsi *vsi);int ice_vsi_manage_rss_lut (struct ice_vsi *vsi,bool ena); +void ice_update_tx_ring_stats (struct ice_ring *ring,u64 pkts,u64 bytes); + +void ice_update_rx_ring_stats (struct ice_ring *ring,u64 pkts,u64 bytes); +void ice_vsi_cfg_frame_size (struct ice_vsi *vsi);u32 ice_intrl_usec_to_reg (u8 intrl,u8 gran);
drivers/net/ethernet/intel/ice/ice_main.c +13 -0
@@ -1734,6 +1734,7 @@ static int ice_xdp_alloc_setup_rings(struct ice_vsi *vsi)if (ice_setup_tx_ring (xdp_ring)) goto free_xdp_rings;ice_set_ring_xdp (xdp_ring); + xdp_ring->xsk_umem =ice_xsk_umem (xdp_ring); }return 0 ;
@@ -1967,6 +1968,14 @@ ice_xdp_setup_prog(struct ice_vsi *vsi, struct bpf_prog *prog,if (if_running) ret =ice_up (vsi); +if (!ret && prog && vsi->xsk_umems) +ice_for_each_rxq (vsi, i) { +struct ice_ring *rx_ring = vsi->rx_rings[i]; + +if (rx_ring->xsk_umem) +napi_schedule (&rx_ring->q_vector->napi); + } + skip_setting_prog:return ret; }
@@ -1993,6 +2002,9 @@ static int ice_xdp(struct net_device *dev, struct netdev_bpf *xdp)case XDP_QUERY_PROG : xdp->prog_id = vsi->xdp_prog ? vsi->xdp_prog->aux->id :0 ;return 0 ; +case XDP_SETUP_XSK_UMEM : +return ice_xsk_umem_setup (vsi, xdp->xsk.umem, + xdp->xsk.queue_id);default :NL_SET_ERR_MSG_MOD (xdp->extack,"Unknown XDP command" );return -EINVAL ;
@@ -5327,4 +5339,5 @@ static const struct net_device_ops ice_netdev_ops = { .ndo_tx_timeout = ice_tx_timeout, .ndo_bpf = ice_xdp, .ndo_xdp_xmit = ice_xdp_xmit, + .ndo_xsk_wakeup = ice_xsk_wakeup, };
drivers/net/ethernet/intel/ice/ice_txrx.c +30 -16
101 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_txrx.h +17 -3
@@ -4,6 +4,8 @@#ifndef _ICE_TXRX_H_#define _ICE_TXRX_H_ +#include "ice_type.h" +#define ICE_DFLT_IRQ_WORK 256#define ICE_RXBUF_2048 2048#define ICE_MAX_CHAINED_RX_BUFS 5
@@ -88,9 +90,17 @@ struct ice_tx_offload_params {struct ice_rx_buf {struct sk_buff *skb;dma_addr_t dma; -struct page *page; -unsigned int page_offset; -u16 pagecnt_bias; +union { +struct { +struct page *page; +unsigned int page_offset; +u16 pagecnt_bias; + }; +struct { +void *addr; +u64 handle; + }; + }; };struct ice_q_stats {
@@ -211,6 +221,8 @@ struct ice_ring {struct rcu_head rcu;/* to avoid race on free */ struct bpf_prog *xdp_prog; +struct xdp_umem *xsk_umem; +struct zero_copy_allocator zca;/* CL3 - 3rd cacheline starts here */ struct xdp_rxq_info xdp_rxq;/* CLX - the below items are only accessed infrequently and should be
@@ -250,6 +262,8 @@ struct ice_ring_container {#define ice_for_each_ring (pos, head) \ for (pos = (head).ring; pos; pos = pos->next) +union ice_32b_rx_flex_desc ; +bool ice_alloc_rx_bufs (struct ice_ring *rxr,u16 cleaned_count);netdev_tx_t ice_start_xmit (struct sk_buff *skb,struct net_device *netdev);void ice_clean_tx_ring (struct ice_ring *tx_ring);
drivers/net/ethernet/intel/ice/ice_xsk.c new file +1181 -0
1,181 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_xsk.h new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
2.20.1
Bowers
PATCH v3 5/9 ice: Add support for AF_XDP
Quoted 29 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Thursday, October 24, 2019 1:11 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S30 v3 5/9] ice: Add support forAF_XDPFrom: Krzysztof Kazimierczak <[email protected]>
Add zero copy
AF_XDPsupport. This patch adds zero copy support for Tx and Rx; code for zero copy is added toice_xsk.handice_xsk.c.For Tx, implement
ndo_xsk_wakeup. As with other drivers, reuse existing XDP Tx queues for this task, sinceXDP_REDIRECTguarantees mutual exclusion between different NAPI contexts based on CPU ID. In turn, a netdev canXDP_REDIRECTto another netdev with a different NAPI context, since the operation is bound to a specific core and each core has its own hardware ring.For Rx, allocate frames as
MEM_TYPE_ZERO_COPYon queues thatAF_XDPis enabled.Signed-off-by Krzysztof Kazimierczak <[email protected]>Co-developed-by Maciej Fijalkowski <[email protected]>Signed-off-by Maciej Fijalkowski <[email protected]>Signed-off-by Tony Nguyen <[email protected]>---
v3:
- Remove unused prototypeice_xsk_umem_query()
Quoted 15 lines
--- drivers/net/ethernet/intel/ice/Makefile | 1 + drivers/net/ethernet/intel/ice/ice.h | 26 + drivers/net/ethernet/intel/ice/ice_base.c | 53 +- drivers/net/ethernet/intel/ice/ice_ethtool.c | 7 + drivers/net/ethernet/intel/ice/ice_lib.c | 57 +- drivers/net/ethernet/intel/ice/ice_lib.h | 4 + drivers/net/ethernet/intel/ice/ice_main.c | 13 + drivers/net/ethernet/intel/ice/ice_txrx.c | 46 +- drivers/net/ethernet/intel/ice/ice_txrx.h | 20 +- drivers/net/ethernet/intel/ice/ice_xsk.c | 1181 ++++++++++++++++++ drivers/net/ethernet/intel/ice/ice_xsk.h | 72 ++ 11 files changed, 1453 insertions(+), 27 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_xsk.c create mode 100644 drivers/net/ethernet/intel/ice/ice_xsk.h
Tony Nguyen
maintainerPATCH v3 6/9 ice: introduce legacy Rx flag
In reply to Tony NguyenFrom: Maciej Fijalkowski <[email protected]>
Add an ethtool "legacy-rx" priv flag for toggling the Rx path. This control knob will be mainly used for build_skb usage as well as buffer size/MTU manipulation.
In preparation for adding build_skb support in a way that it takes care of how we set the values of max_frame and rx_buf_len fields of struct ice_vsi. Specifically, in this patch mentioned fields are set to values that will allow us to provide headroom and tailroom in-place.
This can be mostly broken down onto following:
- for legacy-rx "on" ethtool control knob, old behaviour is kept;
- for standard 1500 MTU size configure the buffer of size 1536, as network stack is expecting the NET_SKB_PAD to be provided and NET_IP_ALIGN can have a non-zero value (these can be typically equal to 32 and 2, respectively);
- for larger MTUs go with max_frame set to 9k and configure the 3k buffer in case when PAGE_SIZE of underlying arch is less than 8k; 3k buffer is implying the need for order 1 page, so that our page recycling scheme can still be applied;
With that said, substitute the hardcoded ICE_RXBUF_2048 and PAGE_SIZE values in DMA API that we're making use of with rx_ring->rx_buf_len and ice_rx_pg_size(rx_ring). The latter is an introduced helper for determining the page size based on its order (which was figured out via ice_rx_pg_order). Last but not least, take care of truesize calculation.
In the followup patch the headroom/tailroom computation logic will be introduced.
This change aligns the buffer and frame configuration with other Intel drivers, most importantly with iavf.
--- drivers/net/ethernet/intel/ice/ice.h | 1 + drivers/net/ethernet/intel/ice/ice_ethtool.c | 6 +++ drivers/net/ethernet/intel/ice/ice_lib.c | 22 +++++++--- drivers/net/ethernet/intel/ice/ice_txrx.c | 46 ++++++++++++-------- drivers/net/ethernet/intel/ice/ice_txrx.h | 13 ++++++ 5 files changed, 63 insertions(+), 25 deletions(-)
drivers/net/ethernet/intel/ice/ice.h +1 -0
@@ -337,6 +337,7 @@ enum ice_pf_flags {ICE_FLAG_NO_MEDIA ,ICE_FLAG_FW_LLDP_AGENT ,ICE_FLAG_ETHTOOL_CTXT ,/* set when ethtool holds RTNL lock */ +ICE_FLAG_LEGACY_RX , ICE_PF_FLAGS_NBITS /* must be last */ };
drivers/net/ethernet/intel/ice/ice_ethtool.c +6 -0
@@ -156,6 +156,7 @@ struct ice_priv_flag {static const struct ice_priv_flag ice_gstrings_priv_flags[] = {ICE_PRIV_FLAG ("link-down-on-close" ,ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA ),ICE_PRIV_FLAG ("fw-lldp-agent" ,ICE_FLAG_FW_LLDP_AGENT ), +ICE_PRIV_FLAG ("legacy-rx" ,ICE_FLAG_LEGACY_RX ), };#define ICE_PRIV_FLAG_ARRAY_SIZE ARRAY_SIZE(ice_gstrings_priv_flags)
@@ -1256,6 +1257,11 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags) "Fail to enable MIB change events\n"); } } +if (test_bit (ICE_FLAG_LEGACY_RX , change_flags)) { +/* down and up VSI so that changes of Rx cfg are reflected. */ +ice_down (vsi); +ice_up (vsi); + }clear_bit (ICE_FLAG_ETHTOOL_CTXT , pf->flags);return ret; }
drivers/net/ethernet/intel/ice/ice_lib.c +16 -6
@@ -1225,12 +1225,22 @@ int ice_vsi_kill_vlan(struct ice_vsi *vsi, u16 vid)*/ void ice_vsi_cfg_frame_size (struct ice_vsi *vsi) { -if (vsi->netdev && vsi->netdev->mtu >ETH_DATA_LEN ) - vsi->max_frame = vsi->netdev->mtu +ICE_ETH_PKT_HDR_PAD ; -else - vsi->max_frame =ICE_RXBUF_2048 ; - - vsi->rx_buf_len =ICE_RXBUF_2048 ; +if (!vsi->netdev ||test_bit (ICE_FLAG_LEGACY_RX , vsi->back->flags)) { + vsi->max_frame =ICE_AQ_SET_MAC_FRAME_SIZE_MAX ; + vsi->rx_buf_len =ICE_RXBUF_2048 ; +#if (PAGE_SIZE <8192 ) + } else if (vsi->netdev->mtu <= ETH_DATA_LEN) { + vsi->max_frame =ICE_RXBUF_1536 -NET_IP_ALIGN ; + vsi->rx_buf_len =ICE_RXBUF_1536 -NET_IP_ALIGN ; +#endif + }else { + vsi->max_frame =ICE_AQ_SET_MAC_FRAME_SIZE_MAX ; +#if (PAGE_SIZE <8192 ) + vsi->rx_buf_len =ICE_RXBUF_3072 ; +#else + vsi->rx_buf_len =ICE_RXBUF_2048 ; +#endif + } }/**
drivers/net/ethernet/intel/ice/ice_txrx.c +27 -19
131 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_txrx.h +13 -0
@@ -7,7 +7,9 @@#include "ice_type.h" #define ICE_DFLT_IRQ_WORK 256 +#define ICE_RXBUF_3072 3072#define ICE_RXBUF_2048 2048 +#define ICE_RXBUF_1536 1536#define ICE_MAX_CHAINED_RX_BUFS 5#define ICE_MAX_BUF_TXD 8#define ICE_MIN_TX_LEN 17
@@ -262,6 +264,17 @@ struct ice_ring_container {#define ice_for_each_ring (pos, head) \ for (pos = (head).ring; pos; pos = pos->next) +static inline unsigned int ice_rx_pg_order (struct ice_ring *ring) +{ +#if (PAGE_SIZE <8192 ) +if (ring->rx_buf_len > (PAGE_SIZE /2 )) +return 1 ; +#endif +return 0 ; +} + +#define ice_rx_pg_size (_ring) (PAGE_SIZE << ice_rx_pg_order(_ring)) +union ice_32b_rx_flex_desc ;bool ice_alloc_rx_bufs (struct ice_ring *rxr,u16 cleaned_count);
Signature · 1 line
2.20.1
Bowers
PATCH v3 6/9 ice: introduce legacy Rx flag
Quoted 43 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Thursday, October 24, 2019 1:11 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S30 v3 6/9] ice: introduce legacy Rx flagFrom: Maciej Fijalkowski <[email protected]>
Add an ethtool "legacy-rx" priv flag for toggling the Rx path. This control knob will be mainly used for
build_skbusage as well as buffer size/MTU manipulation.In preparation for adding
build_skbsupport in a way that it takes care of how we set the values ofmax_frameandrx_buf_lenfields of structice_vsi. Specifically, in this patch mentioned fields are set to values that will allow us to provide headroom and tailroom in-place.This can be mostly broken down onto following:
- for legacy-rx "on" ethtool control knob, old behaviour is kept;
- for standard 1500 MTU size configure the buffer of size 1536, as network stack is expecting theNET_SKB_PADto be provided andNET_IP_ALIGNcan have a non-zero value (these can be typically equal to 32 and 2, respectively);
- for larger MTUs go withmax_frameset to 9k and configure the 3k buffer in case whenPAGE_SIZEof underlying arch is less than 8k; 3k buffer is implying the need for order 1 page, so that our page recycling scheme can still be applied;With that said, substitute the hardcoded
ICE_RXBUF_2048andPAGE_SIZEvalues in DMA API that we're making use of withrx_ring->rx_buf_lenandice_rx_pg_size(rx_ring). The latter is an introduced helper for determining the page size based on its order (which was figured out viaice_rx_pg_order). Last but not least, take care of truesize calculation.In the followup patch the headroom/tailroom computation logic will be introduced.
This change aligns the buffer and frame configuration with other Intel drivers, most importantly with iavf.
Signed-off-by Maciej Fijalkowski <[email protected]>Signed-off-by Tony Nguyen <[email protected]>
Quoted 7 lines
--- drivers/net/ethernet/intel/ice/ice.h | 1 + drivers/net/ethernet/intel/ice/ice_ethtool.c | 6 +++ drivers/net/ethernet/intel/ice/ice_lib.c | 22 +++++++--- drivers/net/ethernet/intel/ice/ice_txrx.c | 46 ++++++++++++-------- drivers/net/ethernet/intel/ice/ice_txrx.h | 13 ++++++ 5 files changed, 63 insertions(+), 25 deletions(-)
Tony Nguyen
maintainerPATCH v3 7/9 ice: introduce frame padding computation logic
In reply to Tony NguyenFrom: Maciej Fijalkowski <[email protected]>
Take into account the underlying architecture specific settings and based on that calculate the possible padding that can be supplied. Typically, for x86 and standard MTU size we will end up with 192 bytes of headroom. This is the same behavior as our other drivers have and we can dedicate it for XDP purposes.
Furthermore, introduce the Rx ring flag for indicating whether build_skb is used on particular. Based on that invoke the routines for padding calculation.
--- drivers/net/ethernet/intel/ice/ice_base.c | 6 ++ drivers/net/ethernet/intel/ice/ice_ethtool.c | 2 +- drivers/net/ethernet/intel/ice/ice_lib.c | 3 +- drivers/net/ethernet/intel/ice/ice_txrx.c | 42 +++++----- drivers/net/ethernet/intel/ice/ice_txrx.h | 81 ++++++++++++++++++++ 5 files changed, 114 insertions(+), 20 deletions(-)
drivers/net/ethernet/intel/ice/ice_base.c +6 -0
@@ -406,6 +406,12 @@ int ice_setup_rx_ctx(struct ice_ring *ring)if (vsi->type ==ICE_VSI_VF )return 0 ; +/* configure Rx buffer alignment */ +if (!vsi->netdev ||test_bit (ICE_FLAG_LEGACY_RX , vsi->back->flags)) +ice_clear_ring_build_skb_ena (ring); +else +ice_set_ring_build_skb_ena (ring); +/* init queue specific tail register */ ring->tail = hw->hw_addr +QRX_TAIL (pf_q);writel (0 , ring->tail);
drivers/net/ethernet/intel/ice/ice_ethtool.c +1 -1
@@ -624,7 +624,7 @@ static int ice_lbtest_receive_frames(struct ice_ring *rx_ring)continue ; rx_buf = &rx_ring->rx_buf[i]; - received_buf =page_address (rx_buf->page); + received_buf =page_address (rx_buf->page) + rx_buf->page_offset;if (ice_lbtest_check_frame (received_buf)) valid_frames++;
drivers/net/ethernet/intel/ice/ice_lib.c +2 -1
@@ -1229,7 +1229,8 @@ void ice_vsi_cfg_frame_size(struct ice_vsi *vsi) vsi->max_frame =ICE_AQ_SET_MAC_FRAME_SIZE_MAX ; vsi->rx_buf_len =ICE_RXBUF_2048 ;#if (PAGE_SIZE <8192 ) - } else if (vsi->netdev->mtu <= ETH_DATA_LEN) { + } else if (!ICE_2K_TOO_SMALL_WITH_PADDING && + (vsi->netdev->mtu <=ETH_DATA_LEN )) { vsi->max_frame =ICE_RXBUF_1536 -NET_IP_ALIGN ; vsi->rx_buf_len =ICE_RXBUF_1536 -NET_IP_ALIGN ;#endif
drivers/net/ethernet/intel/ice/ice_txrx.c +24 -18
65 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_txrx.h +81 -0
99 lines not on this page · raw message
Signature · 1 line
2.20.1
Bowers
PATCH v3 7/9 ice: introduce frame padding computation logic
Quoted 21 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Thursday, October 24, 2019 1:11 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S30 v3 7/9] ice: introduce frame padding computation logicFrom: Maciej Fijalkowski <[email protected]>
Take into account the underlying architecture specific settings and based on that calculate the possible padding that can be supplied. Typically, for x86 and standard MTU size we will end up with 192 bytes of headroom. This is the same behavior as our other drivers have and we can dedicate it for XDP purposes.
Furthermore, introduce the Rx ring flag for indicating whether
build_skbis used on particular. Based on that invoke the routines for padding calculation.Signed-off-by Maciej Fijalkowski <[email protected]>Signed-off-by Tony Nguyen <[email protected]>
Quoted 7 lines
--- drivers/net/ethernet/intel/ice/ice_base.c | 6 ++ drivers/net/ethernet/intel/ice/ice_ethtool.c | 2 +- drivers/net/ethernet/intel/ice/ice_lib.c | 3 +- drivers/net/ethernet/intel/ice/ice_txrx.c | 42 +++++----- drivers/net/ethernet/intel/ice/ice_txrx.h | 81 ++++++++++++++++++++ 5 files changed, 114 insertions(+), 20 deletions(-)
Tony Nguyen
maintainerPATCH v3 8/9 ice: add build_skb() support
In reply to Tony NguyenFrom: Maciej Fijalkowski <[email protected]>
Driver is now prepared for building the skb around the existing Rx buffer, so introduce the ice_build_skb responsible for it. Make use of XDP's data_meta as well.
I've observed around 30% less CPU consumption with build_skb Rx path, in comparison to legacy Rx. What stands behind such result is the avoidance of flow_dissector (which we were diving into via eth_get_headlen) and no memcpy calls.
--- drivers/net/ethernet/intel/ice/ice_txrx.c | 60 ++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_txrx.c +59 -1
@@ -790,6 +790,60 @@ ice_get_rx_buf(struct ice_ring *rx_ring, struct sk_buff **skb,return rx_buf; } +/** +* ice_build_skb - Build skb around an existing buffer +* @rx_ring: Rx descriptor ring to transact packets on +* @rx_buf: Rx buffer to pull data from +* @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 * +ice_build_skb (struct ice_ring *rx_ring,struct ice_rx_buf *rx_buf, +struct xdp_buff *xdp) +{ +unsigned int metasize = xdp->data - xdp->data_meta; +#if (PAGE_SIZE <8192 ) +unsigned int truesize =ice_rx_pg_size (rx_ring) /2 ; +#else +unsigned int truesize =SKB_DATA_ALIGN (sizeof (struct skb_shared_info )) + +SKB_DATA_ALIGN (xdp->data_end - + xdp->data_hard_start); +#endif +struct sk_buff *skb; + +/* Prefetch first cache line of first page. If xdp->data_meta +* is unused, this points exactly as xdp->data, otherwise we +* likely have a consumer accessing first few bytes of meta +* data, and then actual data. +*/ +prefetch (xdp->data_meta); +#if L1_CACHE_BYTES <128 +prefetch ((void *)(xdp->data +L1_CACHE_BYTES )); +#endif +/* build an skb around the page buffer */ + skb =build_skb (xdp->data_hard_start, truesize); +if (unlikely (!skb)) +return NULL ; + +/* must to record Rx queue, otherwise OS features such as +* symmetric queue won't work +*/ +skb_record_rx_queue (skb, rx_ring->q_index); + +/* update pointers within the skb to store the data */ +skb_reserve (skb, xdp->data - xdp->data_hard_start); +__skb_put (skb, xdp->data_end - xdp->data); +if (metasize) +skb_metadata_set (skb, metasize); + +/* buffer is used by skb, update page_offset */ +ice_rx_buf_adjust_pg_offset (rx_buf, truesize); + +return skb; +} +/** * ice_construct_skb - Allocate skb and populate it * @rx_ring: Rx descriptor ring to transact packets on
@@ -996,12 +1050,14 @@ static int ice_clean_rx_irq(struct ice_ring *rx_ring, int budget)if (!size) { xdp.data =NULL ; xdp.data_end =NULL ; + xdp.data_hard_start =NULL ; + xdp.data_meta =NULL ; goto construct_skb; } xdp.data =page_address (rx_buf->page) + rx_buf->page_offset; xdp.data_hard_start = xdp.data -ice_rx_offset (rx_ring); -xdp_set_data_meta_invalid (&xdp); + xdp.data_meta = xdp.data; xdp.data_end = xdp.data + size;rcu_read_lock ();
@@ -1038,6 +1094,8 @@ static int ice_clean_rx_irq(struct ice_ring *rx_ring, int budget) construct_skb:if (skb)ice_add_rx_frag (rx_ring, rx_buf, skb, size); +else if (ice_ring_uses_build_skb (rx_ring)) + skb =ice_build_skb (rx_ring, rx_buf, &xdp);else skb =ice_construct_skb (rx_ring, rx_buf, &xdp);
Signature · 1 line
2.20.1
Bowers
PATCH v3 8/9 ice: add build_skb() support
Quoted 18 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Thursday, October 24, 2019 1:11 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S30 v3 8/9] ice: addbuild_skb()supportFrom: Maciej Fijalkowski <[email protected]>
Driver is now prepared for building the skb around the existing Rx buffer, so introduce the
ice_build_skbresponsible for it. Make use of XDP'sdata_metaas well.I've observed around 30% less CPU consumption with
build_skbRx path, in comparison to legacy Rx. What stands behind such result is the avoidance offlow_dissector(which we were diving into viaeth_get_headlen) and no memcpy calls.
Quoted 4 lines
Signed-off-by Maciej Fijalkowski <[email protected]>--- drivers/net/ethernet/intel/ice/ice_txrx.c | 60 ++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-)
Tony Nguyen
maintainerPATCH v3 9/9 ice: allow 3k MTU for XDP
In reply to Tony NguyenFrom: Maciej Fijalkowski <[email protected]>
At this point ice driver is able to work on order 1 pages that are split onto two 3k buffers. Let's reflect that when user is setting new mtu size and XDP is present on interface.
--- drivers/net/ethernet/intel/ice/ice_main.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +14 -2
@@ -4765,6 +4765,18 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type)dev_err (dev,"Rebuild failed, unload and reload driver\n" ); } +/** +* ice_max_xdp_frame_size - returns the maximum allowed frame size for XDP +* @vsi: Pointer to VSI structure +*/ +static int ice_max_xdp_frame_size (struct ice_vsi *vsi) +{ +if (PAGE_SIZE >=8192 ||test_bit (ICE_FLAG_LEGACY_RX , vsi->back->flags)) +return ICE_RXBUF_2048 -XDP_PACKET_HEADROOM ; +else +return ICE_RXBUF_3072 ; +} +/** * ice_change_mtu - NDO callback to change the MTU * @netdev: network interface device structure
@@ -4786,11 +4798,11 @@ static int ice_change_mtu(struct net_device *netdev, int new_mtu) }if (ice_is_xdp_ena_vsi (vsi)) { -int frame_size =ICE_RXBUF_2048 -XDP_PACKET_HEADROOM ; +int frame_size =ice_max_xdp_frame_size (vsi);if (new_mtu +ICE_ETH_PKT_HDR_PAD > frame_size) {netdev_err (netdev,"max MTU for XDP usage is %d\n" , - frame_size); + frame_size -ICE_ETH_PKT_HDR_PAD );return -EINVAL ; } }
Signature · 1 line
2.20.1
Bowers
PATCH v3 9/9 ice: allow 3k MTU for XDP
Quoted 13 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Thursday, October 24, 2019 1:11 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S30 v3 9/9] ice: allow 3k MTU for XDPFrom: Maciej Fijalkowski <[email protected]>
At this point ice driver is able to work on order 1 pages that are split onto two 3k buffers. Let's reflect that when user is setting new mtu size and XDP is present on interface.
Quoted 5 lines
Signed-off-by Maciej Fijalkowski <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-)
Bowers
PATCH v3 1/9 ice: Introduce ice_base.c
In reply to Tony NguyenQuoted 17 lines
-----Original Message-----
From: Intel-wired-lan [mailto:intel-wired-lan-bounces at osuosl.org] On Behalf Of Tony Nguyen
Sent: Thursday, October 24, 2019 1:11 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S30 v3 1/9] ice: Introduceice_base.cFrom: Anirudh Venkataramanan <[email protected]>
Remove a few uses of kernel configuration flags from
ice_lib.cby introducing a new source fileice_base.c. Also move corresponding function prototypes fromice_lib.htoice_base.hand includeice_base.hwhere required.Signed-off-by: Anirudh Venkataramanan
<[email protected]>Signed-off-by Tony Nguyen <[email protected]>
Quoted 14 lines
--- drivers/net/ethernet/intel/ice/Makefile | 1 + drivers/net/ethernet/intel/ice/ice.h | 8 + drivers/net/ethernet/intel/ice/ice_base.c | 767 +++++++++++++++++ drivers/net/ethernet/intel/ice/ice_base.h | 31 + drivers/net/ethernet/intel/ice/ice_dcb_lib.h | 1 + drivers/net/ethernet/intel/ice/ice_lib.c | 787 +----------------- drivers/net/ethernet/intel/ice/ice_lib.h | 39 - drivers/net/ethernet/intel/ice/ice_main.c | 1 + drivers/net/ethernet/intel/ice/ice_txrx.h | 2 - .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 1 + 10 files changed, 811 insertions(+), 827 deletions(-) create mode 100644 drivers/net/ethernet/intel/ice/ice_base.c create mode 100644 drivers/net/ethernet/intel/ice/ice_base.h