ice: Add DSCP support
Subsystems (2)
Tony Nguyen
maintainerPATCH v2 3/7 ice: Add DSCP support
From: Dave Ertman <[email protected]>
Implement the code to handle submission of APP TLV's containing DSCP to TC mapping.
The first such mapping received on an interface
will cause that PF to switch to L3 DSCP QoS mode,
apply the default config for that mode, and apply
the received mapping.
Only one such mapping will be allowed per DSCP value, and when the last DSCP mapping is deleted, the PF will switch back into L2 VLAN QoS mode, applying the appropriate default QoS settings.
L3 DSCP QoS mode will only be allowed in SW DCBx mode, in other words, when the FW LLDP engine is disabled. Commands that break this mutual exclusivity will be blocked.
---
v2:
- Add implementation for ndo_select_queue to remap the priority to match the DSCP2UP data
- Adjust ice_get_pfc_mode() to return 0 instead of -EOPNOTSUPP when CONFIG_DCB is not defined
--- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 18 ++ drivers/net/ethernet/intel/ice/ice_dcb.c | 225 ++++++++++++++++-- drivers/net/ethernet/intel/ice/ice_dcb.h | 19 ++ drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 7 +- drivers/net/ethernet/intel/ice/ice_dcb_lib.h | 12 + drivers/net/ethernet/intel/ice/ice_dcb_nl.c | 188 ++++++++++++--- drivers/net/ethernet/intel/ice/ice_ethtool.c | 7 + drivers/net/ethernet/intel/ice/ice_main.c | 1 + drivers/net/ethernet/intel/ice/ice_txrx.c | 34 +++ drivers/net/ethernet/intel/ice/ice_txrx.h | 3 + drivers/net/ethernet/intel/ice/ice_type.h | 10 +- 11 files changed, 468 insertions(+), 56 deletions(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +18 -0
@@ -671,6 +671,19 @@ struct ice_aqc_sw_rules_elem { }__packed pdata; }; +/* Query PFC Mode (direct 0x0302) +* Set PFC Mode (direct 0x0303) +*/ +struct ice_aqc_set_query_pfc_mode { +u8 pfc_mode; +/* For Set Command response, reserved in all other cases */ +#define ICE_AQC_PFC_NOT_CONFIGURED 0 +/* For Query Command response, reserved in all other cases */ +#define ICE_AQC_DCB_DIS 0 +#define ICE_AQC_PFC_VLAN_BASED_PFC 1 +#define ICE_AQC_PFC_DSCP_BASED_PFC 2 +u8 rsvd[15 ]; +};/* Get Default Topology (indirect 0x0400) */ struct ice_aqc_get_topo {u8 port_num;
@@ -1936,6 +1949,7 @@ struct ice_aq_desc {struct ice_aqc_nvm_pkg_data pkg_data;struct ice_aqc_nvm_pass_comp_tbl pass_comp_tbl;struct ice_aqc_pf_vf_msg virt; +struct ice_aqc_set_query_pfc_mode set_query_pfc_mode;struct ice_aqc_lldp_get_mib lldp_get_mib;struct ice_aqc_lldp_set_mib_change lldp_set_event;struct ice_aqc_lldp_stop lldp_stop;
@@ -2040,6 +2054,10 @@ enum ice_adminq_opc { ice_aqc_opc_clear_pf_cfg =0x02A4 , +/* DCB commands */ + ice_aqc_opc_query_pfc_mode =0x0302 , + ice_aqc_opc_set_pfc_mode =0x0303 , +/* transmit scheduler commands */ ice_aqc_opc_get_dflt_topo =0x0400 , ice_aqc_opc_add_sched_elems = 0x0401,
drivers/net/ethernet/intel/ice/ice_dcb.c +209 -16
243 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_dcb.h +19 -0
@@ -22,6 +22,14 @@#define ICE_CEE_DCBX_OUI 0x001B21#define ICE_CEE_DCBX_TYPE 2 + +#define ICE_DSCP_OUI 0xFFFFFF +#define ICE_DSCP_SUBTYPE_DSCP2UP 0x41 +#define ICE_DSCP_SUBTYPE_ENFORCE 0x42 +#define ICE_DSCP_SUBTYPE_TCBW 0x43 +#define ICE_DSCP_SUBTYPE_PFC 0x44 +#define ICE_DSCP_IPV6_OFFSET 80 +#define ICE_CEE_SUBTYPE_PG_CFG 2#define ICE_CEE_SUBTYPE_PFC_CFG 3#define ICE_CEE_SUBTYPE_APP_PRI 4
@@ -78,11 +86,20 @@#define ICE_IEEE_TLV_ID_APP_PRI 6#define ICE_TLV_ID_END_OF_LLDPPDU 7#define ICE_TLV_ID_START ICE_IEEE_TLV_ID_ETS_CFG +#define ICE_TLV_ID_DSCP_UP 3 +#define ICE_TLV_ID_DSCP_ENF 4 +#define ICE_TLV_ID_DSCP_TC_BW 5 +#define ICE_TLV_ID_DSCP_TO_PFC 6#define ICE_IEEE_ETS_TLV_LEN 25#define ICE_IEEE_PFC_TLV_LEN 6#define ICE_IEEE_APP_TLV_LEN 11 +#define ICE_DSCP_UP_TLV_LEN 148 +#define ICE_DSCP_ENF_TLV_LEN 132 +#define ICE_DSCP_TC_BW_TLV_LEN 25 +#define ICE_DSCP_PFC_TLV_LEN 6 +/* IEEE 802.1AB LLDP Organization specific TLV */ struct ice_lldp_org_tlv {__be16 typelen;
@@ -120,6 +137,8 @@ struct ice_cee_app_prio {u8 prio_map; } __packed; +enum ice_status +ice_aq_set_pfc_mode (struct ice_hw *hw,u8 pfc_mode,struct ice_sq_cd *cd);enum ice_status ice_aq_get_dcb_cfg (struct ice_hw *hw,u8 mib_type,u8 bridgetype,struct ice_dcbx_cfg *dcbcfg);
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +6 -1
@@ -544,7 +544,7 @@ static int ice_dcb_init_cfg(struct ice_pf *pf, bool locked)* @ets_willing: configure ETS willing * @locked: was this function called with RTNL held */ -static int ice_dcb_sw_dflt_cfg (struct ice_pf *pf,bool ets_willing,bool locked) +int ice_dcb_sw_dflt_cfg (struct ice_pf *pf,bool ets_willing,bool locked) {struct ice_aqc_port_ets_elem buf = {0 };struct ice_dcbx_cfg *dcbcfg;
@@ -726,6 +726,11 @@ int ice_init_pf_dcb(struct ice_pf *pf, bool locked)/* FW LLDP is disabled, activate SW DCBX/LLDP mode */ dev_info (dev,"FW LLDP is disabled, DCBx/LLDP in SW mode.\n" );clear_bit (ICE_FLAG_FW_LLDP_AGENT , pf->flags); + err =ice_aq_set_pfc_mode (&pf->hw,ICE_AQC_PFC_VLAN_BASED_PFC , +NULL ); +if (err) +dev_info (dev,"Failed to set VLAN PFC mode\n" ); + err =ice_dcb_sw_dflt_cfg (pf, true, locked);if (err) { dev_err(dev, "Failed to set local DCB config %d\n",
drivers/net/ethernet/intel/ice/ice_dcb_lib.h +12 -0
@@ -15,6 +15,7 @@#define ICE_DCB_HW_CHG 2/* DCB configuration changed, no reset */ void ice_dcb_rebuild (struct ice_pf *pf); +int ice_dcb_sw_dflt_cfg (struct ice_pf *pf,bool ets_willing,bool locked);u8 ice_dcb_get_ena_tc (struct ice_dcbx_cfg *dcbcfg);u8 ice_dcb_get_num_tc (struct ice_dcbx_cfg *dcbcfg);void ice_vsi_set_dcb_tc_cfg (struct ice_vsi *vsi);
@@ -59,6 +60,12 @@ static inline bool ice_is_dcb_active(struct ice_pf *pf)return (test_bit (ICE_FLAG_FW_LLDP_AGENT , pf->flags) || test_bit(ICE_FLAG_DCB_ENA, pf->flags)); } + +static inline u8 ice_get_pfc_mode (struct ice_pf *pf) +{ +return pf->hw.port_info->qos_cfg.local_dcbx_cfg.pfc_mode; +} +#else static inline void ice_dcb_rebuild (struct ice_pf *pf) { }
@@ -113,6 +120,11 @@ ice_is_pfc_causing_hung_q(struct ice_pf __always_unused *pf,return false; } +static inline u8 ice_get_pfc_mode (struct ice_pf *pf) +{ +return 0 ; +} +static inline void ice_pf_dcb_recfg (struct ice_pf *pf) { }static inline void ice_vsi_cfg_dcb_rings (struct ice_vsi *vsi) { }static inline void ice_update_dcb_stats (struct ice_pf *pf) { }
drivers/net/ethernet/intel/ice/ice_dcb_nl.c +150 -38
279 lines not on this page · raw message
drivers/net/ethernet/intel/ice/ice_ethtool.c +7 -0
@@ -1218,6 +1218,13 @@ static int ice_set_priv_flags(struct net_device *netdev, u32 flags)enum ice_status status;bool dcbx_agent_status; +if (ice_get_pfc_mode (pf) ==ICE_QOS_MODE_DSCP ) { +clear_bit (ICE_FLAG_FW_LLDP_AGENT , pf->flags); +dev_err (dev,"QoS in L3 DSCP mode, FW Agent not allowed to start\n" ); + ret = -EOPNOTSUPP ; + goto ethtool_exit; + } +/* Remove rule to direct LLDP packets to default VSI. * The FW LLDP engine will now be consuming them. */
drivers/net/ethernet/intel/ice/ice_main.c +1 -0
@@ -7307,6 +7307,7 @@ static const struct net_device_ops ice_netdev_ops = { .ndo_open = ice_open, .ndo_stop = ice_stop, .ndo_start_xmit = ice_start_xmit, + .ndo_select_queue = ice_select_queue, .ndo_features_check = ice_features_check, .ndo_set_rx_mode = ice_set_rx_mode, .ndo_set_mac_address = ice_set_mac_address,
drivers/net/ethernet/intel/ice/ice_txrx.c +34 -0
@@ -6,6 +6,7 @@#include <linux/prefetch.h> #include <linux/mm.h> #include <linux/bpf_trace.h> +#include <net/dsfield.h> #include <net/xdp.h> #include "ice_txrx_lib.h" #include "ice_lib.h"
@@ -2383,6 +2384,39 @@ netdev_tx_t ice_start_xmit(struct sk_buff *skb, struct net_device *netdev)return ice_xmit_frame_ring (skb, tx_ring); } +/** +* ice_get_dscp_up - return the UP/TC value for a SKB +* @dcbcfg: DCB config that contains DSCP to UP/TC mapping +* @skb: SKB to query for info to determine UP/TC +* +* This function is to only be called when the PF is in L3 DSCP PFC mode +*/ +static u8 ice_get_dscp_up (struct ice_dcbx_cfg *dcbcfg,struct sk_buff *skb) +{ +u8 dscp =0 ; + +if (skb->protocol ==htons (ETH_P_IP )) + dscp =ipv4_get_dsfield (ip_hdr (skb)) >>2 ; +else if (skb->protocol ==htons (ETH_P_IPV6 )) + dscp =ipv6_get_dsfield (ipv6_hdr (skb)) >>2 ; + +return dcbcfg->dscp_map[dscp]; +} + +u16 +ice_select_queue (struct net_device *netdev,struct sk_buff *skb, +struct net_device *sb_dev) +{ +struct ice_pf *pf =ice_netdev_to_pf (netdev); +struct ice_dcbx_cfg *dcbcfg; + + dcbcfg = &pf->hw.port_info->qos_cfg.local_dcbx_cfg; +if (dcbcfg->pfc_mode ==ICE_QOS_MODE_DSCP ) + skb->priority =ice_get_dscp_up (dcbcfg, skb); + +return netdev_pick_tx (netdev, skb, sb_dev); +} +/** * ice_clean_ctrl_tx_irq - interrupt handler for flow director Tx queue * @tx_ring: tx_ring to clean
drivers/net/ethernet/intel/ice/ice_txrx.h +3 -0
@@ -382,6 +382,9 @@ 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); +u16 +ice_select_queue (struct net_device *dev,struct sk_buff *skb, +struct net_device *sb_dev);void ice_clean_tx_ring (struct ice_ring *tx_ring);void ice_clean_rx_ring (struct ice_ring *rx_ring);int ice_setup_tx_ring (struct ice_ring *tx_ring);
drivers/net/ethernet/intel/ice/ice_type.h +9 -1
@@ -626,7 +626,8 @@ struct ice_dcb_app_priority_table { };#define ICE_MAX_USER_PRIORITY 8 -#define ICE_DCBX_MAX_APPS 32 +#define ICE_DCBX_MAX_APPS 64 +#define ICE_DSCP_NUM_VAL 64#define ICE_LLDPDU_SIZE 1500#define ICE_TLV_STATUS_OPER 0x1#define ICE_TLV_STATUS_SYNC 0x2
@@ -644,7 +645,14 @@ struct ice_dcbx_cfg {struct ice_dcb_ets_cfg etscfg;struct ice_dcb_ets_cfg etsrec;struct ice_dcb_pfc_cfg pfc; +#define ICE_QOS_MODE_VLAN 0x0 +#define ICE_QOS_MODE_DSCP 0x1 +u8 pfc_mode;struct ice_dcb_app_priority_table app[ICE_DCBX_MAX_APPS ]; +/* when DSCP mapping defined by user set its bit to 1 */ +DECLARE_BITMAP (dscp_mapped,ICE_DSCP_NUM_VAL ); +/* array holding DSCP -> UP/TC values for DSCP L3 QoS mode */ +u8 dscp_map[ICE_DSCP_NUM_VAL ];u8 dcbx_mode;#define ICE_DCBX_MODE_CEE 0x1#define ICE_DCBX_MODE_IEEE 0x2
Signature · 1 line
2.20.1
A message that is not in the archive (sent off-list or not yet received): BYAPR11MB3367187CE2A153676BE1544CFCD39@BYAPR11MB3367.namprd11.prod.outlook.com
G
PATCH v2 3/7 ice: Add DSCP support
Quoted 38 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Saturday, August 7, 2021 2:24 AM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH v2 net-next 3/7] ice: Add DSCP supportFrom: Dave Ertman <[email protected]>
Implement the code to handle submission of APP TLV's containing DSCP to TC mapping.
The first such mapping received on an interface will cause that PF to switch to
L3 DSCP QoS mode, apply the default config for that mode, and apply the received mapping.Only one such mapping will be allowed per DSCP value, and when the last DSCP mapping is deleted, the PF will switch back into L2 VLAN QoS mode, applying the appropriate default QoS settings.
L3 DSCP QoS mode will only be allowed in SW DCBx mode, in other words, when the FW LLDP engine is disabled. Commands that break this mutual exclusivity will be blocked.
Co-developed-by: Anirudh Venkataramanan
<[email protected]>
Signed-off-by: Anirudh Venkataramanan
<[email protected]>Signed-off-by Dave Ertman <[email protected]>Signed-off-by Tony Nguyen <[email protected]>---
v2:
- Add implementation forndo_select_queueto remap the priority to match the DSCP2UP data
- Adjustice_get_pfc_mode()to return 0 instead of-EOPNOTSUPPwhenCONFIG_DCBis not defined
Quoted 14 lines
--- .../net/ethernet/intel/ice/ice_adminq_cmd.h | 18 ++ drivers/net/ethernet/intel/ice/ice_dcb.c | 225 ++++++++++++++++-- drivers/net/ethernet/intel/ice/ice_dcb.h | 19 ++ drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 7 +- drivers/net/ethernet/intel/ice/ice_dcb_lib.h | 12 + drivers/net/ethernet/intel/ice/ice_dcb_nl.c | 188 ++++++++++++--- drivers/net/ethernet/intel/ice/ice_ethtool.c | 7 + drivers/net/ethernet/intel/ice/ice_main.c | 1 + drivers/net/ethernet/intel/ice/ice_txrx.c | 34 +++ drivers/net/ethernet/intel/ice/ice_txrx.h | 3 + drivers/net/ethernet/intel/ice/ice_type.h | 10 +- 11 files changed, 468 insertions(+), 56 deletions(-)