net: atlantic: QoS implementation
Subsystems (4)
cover net: atlantic: QoS implementation
This patch series adds support for mqprio rate limiters and multi-TC:
* max_rate is supported on both A1 and A2;
* min_rate is supported on A2 only;
This is a joint work of Mark and Dmitry.
To implement this feature, a couple of rearrangements and code improvements were done, in areas of TC/ring management, allocation control, etc.
One of the problems we faced is conflicting ptp functionality, which due to hardware limitations consumes whole traffic class. Patches below has more detailed description on how this coexist now.
Dmitry Bezrukov (4):
net: atlantic: changes for multi-TC support
net: atlantic: move PTP TC initialization to a separate function
net: atlantic: changes for multi-TC support
net: atlantic: QoS implementation: multi-TC support
Mark Starovoytov (8):
net: atlantic: per-TC queue statistics
net: atlantic: make TCVEC2RING accept nic_cfg
net: atlantic: QoS implementation: max_rate
net: atlantic: automatically downgrade the number of queues if
necessary
net: atlantic: always use random TC-queue mapping for TX on A2.
net: atlantic: change the order of arguments for TC weight/credit
setters
net: atlantic: QoS implementation: min_rate
net: atlantic: proper rss_ctrl1 (54c0) initialization
.../net/ethernet/aquantia/atlantic/aq_cfg.h | 3 + .../ethernet/aquantia/atlantic/aq_ethtool.c | 74 +++-- .../ethernet/aquantia/atlantic/aq_filters.c | 11 +- .../net/ethernet/aquantia/atlantic/aq_hw.h | 20 +- .../ethernet/aquantia/atlantic/aq_hw_utils.c | 26 ++ .../ethernet/aquantia/atlantic/aq_hw_utils.h | 2 + .../net/ethernet/aquantia/atlantic/aq_main.c | 72 ++++- .../net/ethernet/aquantia/atlantic/aq_nic.c | 266 ++++++++++++---- .../net/ethernet/aquantia/atlantic/aq_nic.h | 27 +- .../ethernet/aquantia/atlantic/aq_pci_func.c | 3 + .../net/ethernet/aquantia/atlantic/aq_ptp.c | 27 +- .../net/ethernet/aquantia/atlantic/aq_ring.c | 19 +- .../net/ethernet/aquantia/atlantic/aq_vec.c | 72 +++-- .../net/ethernet/aquantia/atlantic/aq_vec.h | 8 +- .../aquantia/atlantic/hw_atl/hw_atl_a0.c | 10 +- .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 255 ++++++++++----- .../aquantia/atlantic/hw_atl/hw_atl_b0.h | 2 + .../atlantic/hw_atl/hw_atl_b0_internal.h | 6 +- .../aquantia/atlantic/hw_atl/hw_atl_llh.c | 65 +++- .../aquantia/atlantic/hw_atl/hw_atl_llh.h | 32 +- .../atlantic/hw_atl/hw_atl_llh_internal.h | 101 +++++- .../aquantia/atlantic/hw_atl2/hw_atl2.c | 301 +++++++++++++----- .../atlantic/hw_atl2/hw_atl2_internal.h | 12 +- .../aquantia/atlantic/hw_atl2/hw_atl2_llh.c | 36 ++- .../aquantia/atlantic/hw_atl2/hw_atl2_llh.h | 19 +- .../atlantic/hw_atl2/hw_atl2_llh_internal.h | 111 +++++-- 26 files changed, 1200 insertions(+), 380 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/12 net: atlantic: changes for multi-TC support
From: Dmitry Bezrukov <[email protected]>
This patch contains various improvements and cleanups to easeup further TC infrastructure implementation.
We do:
* access cfg via aq_nic_get_cfg() in aq_nic_start() and aq_nic_map_skb();
* call aq_nic_get_dev() just once in aq_nic_map_skb();
* move ring allocation/deallocation out of aq_vec_alloc()/aq_vec_free();
* add the missing aq_nic_deinit() in atl_resume_common();
* rename 'tcs' field to 'tcs_max' in aq_hw_caps_s to differentiate it from the 'tcs' field in aq_nic_cfg_s, which is used for the current number of TCs;
* update _TC_MAX defines to the actual number of supported TCs;
* move tx_tc_mode register defines slightly higher (just to keep the order of definitions);
* separate variables for TX/RX buff_size in hw_atl*_hw_qos_set()'
* use AQ_HW_*_TC instead of hardcoded magic numbers
--- .../net/ethernet/aquantia/atlantic/aq_hw.h | 4 +- .../net/ethernet/aquantia/atlantic/aq_nic.c | 43 +++++++++++------ .../ethernet/aquantia/atlantic/aq_pci_func.c | 3 ++ .../net/ethernet/aquantia/atlantic/aq_vec.c | 47 ++++++++++++------- .../net/ethernet/aquantia/atlantic/aq_vec.h | 3 ++ .../aquantia/atlantic/hw_atl/hw_atl_a0.c | 2 +- .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 34 ++++++-------- .../atlantic/hw_atl/hw_atl_b0_internal.h | 2 +- .../atlantic/hw_atl/hw_atl_llh_internal.h | 31 +++++++----- .../aquantia/atlantic/hw_atl2/hw_atl2.c | 4 +- .../atlantic/hw_atl2/hw_atl2_internal.h | 2 +- 11 files changed, 104 insertions(+), 71 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +3 -1
@@ -46,7 +46,7 @@ struct aq_hw_caps_s {u32 mac_regs_count;u32 hw_alive_check_addr;u8 msix_irqs; -u8 tcs; +u8 tcs_max;u8 rxd_alignment;u8 rxd_size;u8 txd_alignment;
@@ -120,6 +120,8 @@ struct aq_stats_s {#define AQ_HW_MULTICAST_ADDRESS_MAX 32U +#define AQ_HW_PTP_TC 2U +#define AQ_HW_LED_BLINK 0x2U#define AQ_HW_LED_DEFAULT 0x0U
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +28 -15
128 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/aq_pci_func.c +3 -0
@@ -431,6 +431,9 @@ static int atl_resume_common(struct device *dev, bool deep)netif_tx_start_all_queues (nic->ndev); err_exit: +if (ret <0 ) +aq_nic_deinit (nic, true); +rtnl_unlock ();return ret;
drivers/net/ethernet/aquantia/atlantic/aq_vec.c +31 -16
87 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/aq_vec.h +3 -0
@@ -25,10 +25,13 @@ irqreturn_t aq_vec_isr(int irq, void *private);irqreturn_t aq_vec_isr_legacy (int irq,void *private);struct aq_vec_s *aq_vec_alloc (struct aq_nic_s *aq_nic,unsigned int idx,struct aq_nic_cfg_s *aq_nic_cfg); +int aq_vec_ring_alloc (struct aq_vec_s *self,struct aq_nic_s *aq_nic, +unsigned int idx,struct aq_nic_cfg_s *aq_nic_cfg);int aq_vec_init (struct aq_vec_s *self,const struct aq_hw_ops *aq_hw_ops,struct aq_hw_s *aq_hw);void aq_vec_deinit (struct aq_vec_s *self);void aq_vec_free (struct aq_vec_s *self); +void aq_vec_ring_free (struct aq_vec_s *self);int aq_vec_start (struct aq_vec_s *self);void aq_vec_stop (struct aq_vec_s *self);cpumask_t *aq_vec_get_affinity_mask (struct aq_vec_s *self);
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c +1 -1
@@ -21,7 +21,7 @@ .msix_irqs = 4U, \ .irq_mask = ~0U, \ .vecs = HW_ATL_A0_RSS_MAX, \ - .tcs = HW_ATL_A0_TC_MAX, \ + .tcs_max = HW_ATL_A0_TC_MAX, \ .rxd_alignment = 1U, \ .rxd_size = HW_ATL_A0_RXD_SIZE, \ .rxds_max = HW_ATL_A0_MAX_RXD, \
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +14 -20
@@ -23,7 +23,7 @@ .msix_irqs = 8U, \ .irq_mask = ~0U, \ .vecs = HW_ATL_B0_RSS_MAX, \ - .tcs = HW_ATL_B0_TC_MAX, \ + .tcs_max = HW_ATL_B0_TC_MAX, \ .rxd_alignment = 1U, \ .rxd_size = HW_ATL_B0_RXD_SIZE, \ .rxds_max = HW_ATL_B0_MAX_RXD, \
@@ -116,8 +116,9 @@ static int hw_atl_b0_set_fc(struct aq_hw_s *self, u32 fc, u32 tc)static int hw_atl_b0_hw_qos_set (struct aq_hw_s *self) { +u32 tx_buff_size =HW_ATL_B0_TXBUF_MAX ; +u32 rx_buff_size =HW_ATL_B0_RXBUF_MAX ;unsigned int i_priority =0U ; -u32 buff_size =0U ;u32 tc =0U ;/* TPS Descriptor rate init */
@@ -131,8 +132,6 @@ static int hw_atl_b0_hw_qos_set(struct aq_hw_s *self)hw_atl_tps_tx_pkt_shed_desc_tc_arb_mode_set (self,0U );hw_atl_tps_tx_pkt_shed_data_arb_mode_set (self,0U ); - tc =0 ; -/* TX Packet Scheduler Data TC0 */ hw_atl_tps_tx_pkt_shed_tc_data_max_credit_set (self,0xFFF , tc);hw_atl_tps_tx_pkt_shed_tc_data_weight_set (self,0x64 , tc);
@@ -140,46 +139,41 @@ static int hw_atl_b0_hw_qos_set(struct aq_hw_s *self)hw_atl_tps_tx_pkt_shed_desc_tc_weight_set (self,0x1E , tc);/* Tx buf size TC0 */ - buff_size =HW_ATL_B0_TXBUF_MAX -HW_ATL_B0_PTP_TXBUF_SIZE ; + tx_buff_size -=HW_ATL_B0_PTP_TXBUF_SIZE ; -hw_atl_tpb_tx_pkt_buff_size_per_tc_set (self, buff_size, tc); +hw_atl_tpb_tx_pkt_buff_size_per_tc_set (self, tx_buff_size, tc);hw_atl_tpb_tx_buff_hi_threshold_per_tc_set (self, - (buff_size * + (tx_buff_size * (1024 /32U ) *66U ) /100U , tc);hw_atl_tpb_tx_buff_lo_threshold_per_tc_set (self, - (buff_size * + (tx_buff_size * (1024 /32U ) *50U ) /100U , tc);/* Init TC2 for PTP_TX */ - tc =2 ; -hw_atl_tpb_tx_pkt_buff_size_per_tc_set (self,HW_ATL_B0_PTP_TXBUF_SIZE , - tc); +AQ_HW_PTP_TC );/* QoS Rx buf size per TC */ - tc =0 ; - buff_size =HW_ATL_B0_RXBUF_MAX -HW_ATL_B0_PTP_RXBUF_SIZE ; + rx_buff_size -=HW_ATL_B0_PTP_RXBUF_SIZE ; -hw_atl_rpb_rx_pkt_buff_size_per_tc_set (self, buff_size, tc); +hw_atl_rpb_rx_pkt_buff_size_per_tc_set (self, rx_buff_size, tc);hw_atl_rpb_rx_buff_hi_threshold_per_tc_set (self, - (buff_size * + (rx_buff_size * (1024U /32U ) *66U ) /100U , tc);hw_atl_rpb_rx_buff_lo_threshold_per_tc_set (self, - (buff_size * + (rx_buff_size * (1024U /32U ) *50U ) /100U , tc);hw_atl_b0_set_fc (self, self->aq_nic_cfg->fc.req, tc);/* Init TC2 for PTP_RX */ - tc =2 ; -hw_atl_rpb_rx_pkt_buff_size_per_tc_set (self,HW_ATL_B0_PTP_RXBUF_SIZE , - tc); +AQ_HW_PTP_TC );/* No flow control for PTP */ -hw_atl_rpb_rx_xoff_en_per_tc_set (self,0U , tc); +hw_atl_rpb_rx_xoff_en_per_tc_set (self,0U ,AQ_HW_PTP_TC );/* QoS 802.1p priority -> TC mapping */ for (i_priority =8U ; i_priority--;)
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0_internal.h +1 -1
@@ -75,7 +75,7 @@#define HW_ATL_B0_RSS_HASHKEY_BITS 320U#define HW_ATL_B0_TCRSS_4_8 1 -#define HW_ATL_B0_TC_MAX 1U +#define HW_ATL_B0_TC_MAX 8U#define HW_ATL_B0_RSS_MAX 8U#define HW_ATL_B0_LRO_RXD_MAX 16U
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh_internal.h +18 -13
@@ -2038,6 +2038,24 @@/* default value of bitfield lso_tcp_flag_mid[b:0] */ #define HW_ATL_THM_LSO_TCP_FLAG_MID_DEFAULT 0x0 +/* tx tx_tc_mode bitfield definitions +* preprocessor definitions for the bitfield "tx_tc_mode". +* port="pif_tpb_tx_tc_mode_i,pif_tps_tx_tc_mode_i" +*/ + +/* register address for bitfield tx_tc_mode */ +#define HW_ATL_TPB_TX_TC_MODE_ADDR 0x00007900 +/* bitmask for bitfield tx_tc_mode */ +#define HW_ATL_TPB_TX_TC_MODE_MSK 0x00000100 +/* inverted bitmask for bitfield tx_tc_mode */ +#define HW_ATL_TPB_TX_TC_MODE_MSKN 0xFFFFFEFF +/* lower bit position of bitfield tx_tc_mode */ +#define HW_ATL_TPB_TX_TC_MODE_SHIFT 8 +/* width of bitfield tx_tc_mode */ +#define HW_ATL_TPB_TX_TC_MODE_WIDTH 1 +/* default value of bitfield tx_tc_mode */ +#define HW_ATL_TPB_TX_TC_MODE_DEFAULT 0x0 +/* tx tx_buf_en bitfield definitions * preprocessor definitions for the bitfield "tx_buf_en". * port="pif_tpb_tx_buf_en_i"
@@ -2056,19 +2074,6 @@/* default value of bitfield tx_buf_en */ #define HW_ATL_TPB_TX_BUF_EN_DEFAULT 0x0 -/* register address for bitfield tx_tc_mode */ -#define HW_ATL_TPB_TX_TC_MODE_ADDR 0x00007900 -/* bitmask for bitfield tx_tc_mode */ -#define HW_ATL_TPB_TX_TC_MODE_MSK 0x00000100 -/* inverted bitmask for bitfield tx_tc_mode */ -#define HW_ATL_TPB_TX_TC_MODE_MSKN 0xFFFFFEFF -/* lower bit position of bitfield tx_tc_mode */ -#define HW_ATL_TPB_TX_TC_MODE_SHIFT 8 -/* width of bitfield tx_tc_mode */ -#define HW_ATL_TPB_TX_TC_MODE_WIDTH 1 -/* default value of bitfield tx_tc_mode */ -#define HW_ATL_TPB_TX_TC_MODE_DEFAULT 0x0 -/* tx tx{b}_hi_thresh[c:0] bitfield definitions * preprocessor definitions for the bitfield "tx{b}_hi_thresh[c:0]". * parameter: buffer {b} | stride size 0x10 | range [0, 7]
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +1 -3
@@ -23,7 +23,7 @@ static int hw_atl2_act_rslvr_table_set(struct aq_hw_s *self, u8 location, .msix_irqs = 8U, \ .irq_mask = ~0U, \ .vecs = HW_ATL2_RSS_MAX, \ - .tcs = HW_ATL2_TC_MAX, \ + .tcs_max = HW_ATL2_TC_MAX, \ .rxd_alignment = 1U, \ .rxd_size = HW_ATL2_RXD_SIZE, \ .rxds_max = HW_ATL2_MAX_RXD, \
@@ -126,8 +126,6 @@ static int hw_atl2_hw_qos_set(struct aq_hw_s *self)hw_atl_tps_tx_pkt_shed_desc_tc_arb_mode_set (self,0U );hw_atl_tps_tx_pkt_shed_data_arb_mode_set (self,0U ); - tc =0 ; -/* TX Packet Scheduler Data TC0 */ hw_atl2_tps_tx_pkt_shed_tc_data_max_credit_set (self,0xFFF0 , tc);hw_atl2_tps_tx_pkt_shed_tc_data_weight_set (self,0x640 , tc);
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h +1 -1
@@ -31,7 +31,7 @@#define HW_ATL2_RSS_REDIRECTION_MAX 64U -#define HW_ATL2_TC_MAX 1U +#define HW_ATL2_TC_MAX 8U#define HW_ATL2_RSS_MAX 8U#define HW_ATL2_INTR_MODER_MAX 0x1FF
Signature · 1 line
2.25.1
PATCH 2/12 net: atlantic: move PTP TC initialization to a separate function
In reply to Igor RusskikhFrom: Dmitry Bezrukov <[email protected]>
This patch moves the PTP TC initialization into a separate function.
--- .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-)
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +19 -12
@@ -114,6 +114,21 @@ static int hw_atl_b0_set_fc(struct aq_hw_s *self, u32 fc, u32 tc)return 0 ; } +static int hw_atl_b0_tc_ptp_set (struct aq_hw_s *self) +{ +/* Init TC2 for PTP_TX */ +hw_atl_tpb_tx_pkt_buff_size_per_tc_set (self,HW_ATL_B0_PTP_TXBUF_SIZE , +AQ_HW_PTP_TC ); + +/* Init TC2 for PTP_RX */ +hw_atl_rpb_rx_pkt_buff_size_per_tc_set (self,HW_ATL_B0_PTP_RXBUF_SIZE , +AQ_HW_PTP_TC ); +/* No flow control for PTP */ +hw_atl_rpb_rx_xoff_en_per_tc_set (self,0U ,AQ_HW_PTP_TC ); + +return aq_hw_err_from_flags (self); +} +static int hw_atl_b0_hw_qos_set (struct aq_hw_s *self) {u32 tx_buff_size =HW_ATL_B0_TXBUF_MAX ;
@@ -121,6 +136,9 @@ static int hw_atl_b0_hw_qos_set(struct aq_hw_s *self)unsigned int i_priority =0U ;u32 tc =0U ; + tx_buff_size -=HW_ATL_B0_PTP_TXBUF_SIZE ; + rx_buff_size -=HW_ATL_B0_PTP_RXBUF_SIZE ; +/* TPS Descriptor rate init */ hw_atl_tps_tx_pkt_shed_desc_rate_curr_time_res_set (self,0x0U );hw_atl_tps_tx_pkt_shed_desc_rate_lim_set (self,0xA );
@@ -139,8 +157,6 @@ static int hw_atl_b0_hw_qos_set(struct aq_hw_s *self)hw_atl_tps_tx_pkt_shed_desc_tc_weight_set (self,0x1E , tc);/* Tx buf size TC0 */ - tx_buff_size -=HW_ATL_B0_PTP_TXBUF_SIZE ; -hw_atl_tpb_tx_pkt_buff_size_per_tc_set (self, tx_buff_size, tc); hw_atl_tpb_tx_buff_hi_threshold_per_tc_set(self, (tx_buff_size *
@@ -150,13 +166,8 @@ static int hw_atl_b0_hw_qos_set(struct aq_hw_s *self) (tx_buff_size * (1024 /32U ) *50U ) / 100U, tc); -/* Init TC2 for PTP_TX */ -hw_atl_tpb_tx_pkt_buff_size_per_tc_set (self,HW_ATL_B0_PTP_TXBUF_SIZE , -AQ_HW_PTP_TC );/* QoS Rx buf size per TC */ - rx_buff_size -=HW_ATL_B0_PTP_RXBUF_SIZE ; -hw_atl_rpb_rx_pkt_buff_size_per_tc_set (self, rx_buff_size, tc); hw_atl_rpb_rx_buff_hi_threshold_per_tc_set(self, (rx_buff_size *
@@ -169,11 +180,7 @@ static int hw_atl_b0_hw_qos_set(struct aq_hw_s *self)hw_atl_b0_set_fc (self, self->aq_nic_cfg->fc.req, tc); -/* Init TC2 for PTP_RX */ -hw_atl_rpb_rx_pkt_buff_size_per_tc_set (self,HW_ATL_B0_PTP_RXBUF_SIZE , -AQ_HW_PTP_TC ); -/* No flow control for PTP */ -hw_atl_rpb_rx_xoff_en_per_tc_set (self,0U ,AQ_HW_PTP_TC ); +hw_atl_b0_tc_ptp_set (self);/* QoS 802.1p priority -> TC mapping */ for (i_priority =8U ; i_priority--;)
Signature · 1 line
2.25.1
PATCH 3/12 net: atlantic: changes for multi-TC support
In reply to Igor RusskikhFrom: Dmitry Bezrukov <[email protected]>
This patch contains the following changes:
* add cfg->is_ptp (used for PTP enable/disable switch, which is described in more details below);
* add cfg->tc_mode (A1 supports 2 HW modes only);
* setup queue to TC mapping based on TC mode on A2;
* remove hw_tx_tc_mode_get / hw_rx_tc_mode_get hw_ops.
In the first generation of our hardware (A1), a whole traffic class is consumed for PTP handling in FW (FW uses it to send the ptp data and to send back timestamps).
Since this conflicts with QoS (user is unable to use the reserved TC2), we suggest using module param to give the user a choice: disabling PTP allows using all available TCs.
--- .../net/ethernet/aquantia/atlantic/aq_cfg.h | 3 ++ .../net/ethernet/aquantia/atlantic/aq_hw.h | 10 +++-- .../net/ethernet/aquantia/atlantic/aq_nic.c | 30 +++++++++----- .../net/ethernet/aquantia/atlantic/aq_nic.h | 2 + .../net/ethernet/aquantia/atlantic/aq_ptp.c | 27 ++++++------- .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 25 ++++-------- .../aquantia/atlantic/hw_atl2/hw_atl2.c | 40 ++++++++++++++----- 7 files changed, 82 insertions(+), 55 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_cfg.h +3 -0
@@ -44,6 +44,9 @@/* LRO */ #define AQ_CFG_IS_LRO_DEF 1U +/* PTP */ +#define AQ_CFG_PTP_DEF 1U +/* RSS */ #define AQ_CFG_RSS_INDIRECTION_TABLE_MAX 64U#define AQ_CFG_RSS_HASHKEY_SIZE 40U
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +6 -4
@@ -18,6 +18,12 @@#define AQ_HW_MAC_COUNTER_HZ 312500000ll#define AQ_HW_PHY_COUNTER_HZ 160000000ll +enum aq_tc_mode { +AQ_TC_MODE_INVALID =-1 , +AQ_TC_MODE_8TCS , +AQ_TC_MODE_4TCS , +}; +#define AQ_RX_FIRST_LOC_FVLANID 0U#define AQ_RX_LAST_LOC_FVLANID 15U#define AQ_RX_FIRST_LOC_FETHERT 16U
@@ -281,10 +287,6 @@ struct aq_hw_ops {int (*hw_set_offload)(struct aq_hw_s *self,struct aq_nic_cfg_s *aq_nic_cfg); -int (*hw_tx_tc_mode_get)(struct aq_hw_s *self,u32 *tc_mode); - -int (*hw_rx_tc_mode_get)(struct aq_hw_s *self,u32 *tc_mode); -int (*hw_ring_hwts_rx_fill)(struct aq_hw_s *self,struct aq_ring_s *aq_ring);
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +21 -9
@@ -39,6 +39,10 @@ static unsigned int aq_itr_rx;module_param_named (aq_itr_rx, aq_itr_rx, uint,0644 );MODULE_PARM_DESC (aq_itr_rx,"RX interrupt throttle rate" ); +static bool aq_enable_ptp =AQ_CFG_PTP_DEF ; +module_param (aq_enable_ptp, bool,0644 ); +MODULE_PARM_DESC (aq_enable_ptp,"Enable PTP" ); +static void aq_nic_update_ndev_stats (struct aq_nic_s *self);static void aq_nic_rss_init (struct aq_nic_s *self,unsigned int num_rss_queues)
@@ -89,6 +93,7 @@ void aq_nic_cfg_start(struct aq_nic_s *self) cfg->is_autoneg =AQ_CFG_IS_AUTONEG_DEF ; cfg->is_lro =AQ_CFG_IS_LRO_DEF ; + cfg->is_ptp = aq_enable_ptp;/*descriptors */ cfg->rxds =min (cfg->aq_hw_caps->rxds_max,AQ_CFG_RXDS_DEF );
@@ -122,6 +127,11 @@ void aq_nic_cfg_start(struct aq_nic_s *self) cfg->vecs =1U ; } +if (cfg->vecs <=4 ) + cfg->tc_mode =AQ_TC_MODE_8TCS ; +else + cfg->tc_mode =AQ_TC_MODE_4TCS ; +/* Check if we have enough vectors allocated for * link status IRQ. If no - we'll know link state from * slower service task.
@@ -409,17 +419,19 @@ int aq_nic_init(struct aq_nic_s *self)aq_vec_init (aq_vec, self->aq_hw_ops, self->aq_hw); } - err =aq_ptp_init (self, self->irqvecs -1 ); -if (err <0 ) - goto err_exit; +if (aq_nic_get_cfg (self)->is_ptp) { + err =aq_ptp_init (self, self->irqvecs -1 ); +if (err <0 ) + goto err_exit; - err =aq_ptp_ring_alloc (self); -if (err <0 ) - goto err_exit; + err =aq_ptp_ring_alloc (self); +if (err <0 ) + goto err_exit; - err =aq_ptp_ring_init (self); -if (err <0 ) - goto err_exit; + err =aq_ptp_ring_init (self); +if (err <0 ) + goto err_exit; + }netif_carrier_off (self->ndev);
drivers/net/ethernet/aquantia/atlantic/aq_nic.h +2 -0
@@ -59,6 +59,8 @@ struct aq_nic_cfg_s {bool is_polling;bool is_rss;bool is_lro; +bool is_ptp; +enum aq_tc_mode tc_mode;u32 priv_flags;u8 tcs;struct aq_rss_parameters aq_rss;
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +13 -14
@@ -945,26 +945,29 @@ void aq_ptp_ring_deinit(struct aq_nic_s *aq_nic)#define PTP_4TC_RING_IDX 16#define PTP_HWST_RING_IDX 31 +/* Index must be 8 (8 TCs) or 16 (4 TCs). +* It depends on Traffic Class mode. +*/ +unsigned int ptp_ring_idx (const enum aq_tc_mode tc_mode) +{ +if (tc_mode ==AQ_TC_MODE_8TCS ) +return PTP_8TC_RING_IDX ; + +return PTP_4TC_RING_IDX ; +} +int aq_ptp_ring_alloc (struct aq_nic_s *aq_nic) {struct aq_ptp_s *aq_ptp = aq_nic->aq_ptp;unsigned int tx_ring_idx, rx_ring_idx;struct aq_ring_s *hwts; -u32 tx_tc_mode, rx_tc_mode;struct aq_ring_s *ring;int err;if (!aq_ptp)return 0 ; -/* Index must to be 8 (8 TCs) or 16 (4 TCs). -* It depends from Traffic Class mode. -*/ - aq_nic->aq_hw_ops->hw_tx_tc_mode_get (aq_nic->aq_hw, &tx_tc_mode); -if (tx_tc_mode ==0 ) - tx_ring_idx =PTP_8TC_RING_IDX ; -else - tx_ring_idx =PTP_4TC_RING_IDX ; + tx_ring_idx =ptp_ring_idx (aq_nic->aq_nic_cfg.tc_mode); ring =aq_ring_tx_alloc (&aq_ptp->ptp_tx, aq_nic, tx_ring_idx, &aq_nic->aq_nic_cfg);
@@ -973,11 +976,7 @@ int aq_ptp_ring_alloc(struct aq_nic_s *aq_nic) goto err_exit; } - aq_nic->aq_hw_ops->hw_rx_tc_mode_get (aq_nic->aq_hw, &rx_tc_mode); -if (rx_tc_mode ==0 ) - rx_ring_idx =PTP_8TC_RING_IDX ; -else - rx_ring_idx =PTP_4TC_RING_IDX ; + rx_ring_idx =ptp_ring_idx (aq_nic->aq_nic_cfg.tc_mode); ring =aq_ring_rx_alloc (&aq_ptp->ptp_rx, aq_nic, rx_ring_idx, &aq_nic->aq_nic_cfg);
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +7 -18
@@ -131,13 +131,16 @@ static int hw_atl_b0_tc_ptp_set(struct aq_hw_s *self)static int hw_atl_b0_hw_qos_set (struct aq_hw_s *self) { +struct aq_nic_cfg_s *cfg = self->aq_nic_cfg;u32 tx_buff_size =HW_ATL_B0_TXBUF_MAX ;u32 rx_buff_size =HW_ATL_B0_RXBUF_MAX ;unsigned int i_priority =0U ;u32 tc =0U ; - tx_buff_size -=HW_ATL_B0_PTP_TXBUF_SIZE ; - rx_buff_size -=HW_ATL_B0_PTP_RXBUF_SIZE ; +if (cfg->is_ptp) { + tx_buff_size -=HW_ATL_B0_PTP_TXBUF_SIZE ; + rx_buff_size -=HW_ATL_B0_PTP_RXBUF_SIZE ; + }/* TPS Descriptor rate init */ hw_atl_tps_tx_pkt_shed_desc_rate_curr_time_res_set (self,0x0U );
@@ -180,7 +183,8 @@ static int hw_atl_b0_hw_qos_set(struct aq_hw_s *self)hw_atl_b0_set_fc (self, self->aq_nic_cfg->fc.req, tc); -hw_atl_b0_tc_ptp_set (self); +if (cfg->is_ptp) +hw_atl_b0_tc_ptp_set (self);/* QoS 802.1p priority -> TC mapping */ for (i_priority =8U ; i_priority--;)
@@ -1079,18 +1083,6 @@ int hw_atl_b0_hw_ring_rx_stop(struct aq_hw_s *self, struct aq_ring_s *ring)return aq_hw_err_from_flags (self); } -static int hw_atl_b0_tx_tc_mode_get (struct aq_hw_s *self,u32 *tc_mode) -{ - *tc_mode =hw_atl_tpb_tps_tx_tc_mode_get (self); -return aq_hw_err_from_flags (self); -} - -static int hw_atl_b0_rx_tc_mode_get (struct aq_hw_s *self,u32 *tc_mode) -{ - *tc_mode =hw_atl_rpb_rpf_rx_traf_class_mode_get (self); -return aq_hw_err_from_flags (self); -} -#define get_ptp_ts_val_u64 (self, indx) \ ((u64)(hw_atl_pcs_ptp_clock_get(self, indx) & 0xffff))
@@ -1508,9 +1500,6 @@ const struct aq_hw_ops hw_atl_ops_b0 = { .hw_get_hw_stats = hw_atl_utils_get_hw_stats, .hw_get_fw_version = hw_atl_utils_get_fw_version, - .hw_tx_tc_mode_get = hw_atl_b0_tx_tc_mode_get, - .hw_rx_tc_mode_get = hw_atl_b0_rx_tc_mode_get, - .hw_ring_hwts_rx_fill = hw_atl_b0_hw_ring_hwts_rx_fill, .hw_ring_hwts_rx_receive = hw_atl_b0_hw_ring_hwts_rx_receive,
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +30 -10
@@ -91,16 +91,36 @@ static int hw_atl2_hw_reset(struct aq_hw_s *self)static int hw_atl2_hw_queue_to_tc_map_set (struct aq_hw_s *self) { -if (!hw_atl_rpb_rpf_rx_traf_class_mode_get (self)) { -aq_hw_write_reg (self,HW_ATL2_RX_Q_TC_MAP_ADR (0 ),0x11110000 ); -aq_hw_write_reg (self,HW_ATL2_RX_Q_TC_MAP_ADR (8 ),0x33332222 ); -aq_hw_write_reg (self,HW_ATL2_RX_Q_TC_MAP_ADR (16 ),0x55554444 ); -aq_hw_write_reg (self,HW_ATL2_RX_Q_TC_MAP_ADR (24 ),0x77776666 ); - }else { -aq_hw_write_reg (self,HW_ATL2_RX_Q_TC_MAP_ADR (0 ),0x00000000 ); -aq_hw_write_reg (self,HW_ATL2_RX_Q_TC_MAP_ADR (8 ),0x11111111 ); -aq_hw_write_reg (self,HW_ATL2_RX_Q_TC_MAP_ADR (16 ),0x22222222 ); -aq_hw_write_reg (self,HW_ATL2_RX_Q_TC_MAP_ADR (24 ),0x33333333 ); +struct aq_nic_cfg_s *cfg = self->aq_nic_cfg; +unsigned int tcs, q_per_tc; +unsigned int tc, q; +u32 value =0 ; + +switch (cfg->tc_mode) { +case AQ_TC_MODE_8TCS : + tcs =8 ; + q_per_tc =4 ; +break ; +case AQ_TC_MODE_4TCS : + tcs =4 ; + q_per_tc =8 ; +break ; +default : +return -EINVAL ; + } + +for (tc =0 ; tc != tcs; tc++) { +unsigned int tc_q_offset = tc * q_per_tc; + +for (q = tc_q_offset; q != tc_q_offset + q_per_tc; q++) + value |= tc <<HW_ATL2_RX_Q_TC_MAP_SHIFT (q); + +if (HW_ATL2_RX_Q_TC_MAP_ADR (q) != +HW_ATL2_RX_Q_TC_MAP_ADR (q -1 )) { +aq_hw_write_reg (self,HW_ATL2_RX_Q_TC_MAP_ADR (q -1 ), + value); + value =0 ; + } }return aq_hw_err_from_flags (self);
Signature · 1 line
2.25.1
Jakub Kicinski
maintainerRe: [PATCH net-next 03/12] net: atlantic: changes for multi-TC support
Quoted 16 lines · On Wed, 20 May 2020 16:47:25 +0300 Igor Russkikh wrote:
From: Dmitry Bezrukov <[email protected]>
This patch contains the following changes:
* addcfg->is_ptp(used for PTP enable/disable switch, which is described in more details below);
* addcfg->tc_mode(A1 supports 2 HW modes only);
* setup queue to TC mapping based on TC mode on A2;
* removehw_tx_tc_mode_get/hw_rx_tc_mode_gethw_ops.In the first generation of our hardware (A1), a whole traffic class is consumed for PTP handling in FW (FW uses it to send the ptp data and to send back timestamps).
Since this conflicts with QoS (user is unable to use the reserved TC2), we suggest using module param to give the user a choice: disabling PTP allows using all available TCs.
Quoted 4 lines
Signed-off-by Dmitry Bezrukov <[email protected]>Co-developed-by Mark Starovoytov <[email protected]>Signed-off-by Mark Starovoytov <[email protected]>Signed-off-by Igor Russkikh <[email protected]>
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c:951:14: warning: no previous prototype for ptp_ring_idx [-Wmissing-prototypes]
951 | unsigned int ptp_ring_idx(const enum aq_tc_mode tc_mode)
| ^~~~~~~~~~~~
Jakub Kicinski
maintainerRe: [PATCH net-next 03/12] net: atlantic: changes for multi-TC support
In reply to Igor RusskikhQuoted 9 lines · On Wed, 20 May 2020 16:47:25 +0300 Igor Russkikh wrote:
From: Dmitry Bezrukov <[email protected]>
This patch contains the following changes:
* addcfg->is_ptp(used for PTP enable/disable switch, which is described in more details below);
* addcfg->tc_mode(A1 supports 2 HW modes only);
* setup queue to TC mapping based on TC mode on A2;
* removehw_tx_tc_mode_get/hw_rx_tc_mode_gethw_ops.
Quoted 6 lines
In the first generation of our hardware (A1), a whole traffic class is consumed for PTP handling in FW (FW uses it to send the ptp data and to send back timestamps).
Since this conflicts with QoS (user is unable to use the reserved TC2), we suggest using module param to give the user a choice: disabling PTP allows using all available TCs.
Is there really no way to get the config automatically chosen when user sets up TCs or does SIOCSHWTSTAMP? It's fine to return -EOPNOTSUPP when too many things are enabled, but user having to set module parameters upfront is quite painful.
RE: [EXT] Re: [PATCH net-next 03/12] net: atlantic: changes for multi-TC support
Hi Jakub,
Quoted 11 lines
Quoted 6 lines
In the first generation of our hardware (A1), a whole traffic class is consumed for PTP handling in FW (FW uses it to send the ptp data and to send back timestamps).
Since this conflicts with QoS (user is unable to use the reserved TC2), we suggest using module param to give the user a choice:
disabling PTP allows using all available TCs.Is there really no way to get the config automatically chosen when user sets up TCs or does SIOCSHWTSTAMP? It's fine to return
-EOPNOTSUPPwhen too many things are enabled, but user having to set module parameters upfront is quite painful.
Module param is not a must have for usage, default config allows the user to use TCs and PTP features simultaneously with one major limitation: TC2 is reserved for PTP, so if the user tries to send/receive anything on TC2, if won't quite work unfortunately. If the user wants to get "everything" from QoS/TC (e.g. use all the TCs) - he can explicitly disable the PTP via module param.
Right now we really aren't sure we can dynamically rearrange resources between QoS and PTP, since disabling/enabling PTP requires a complete HW reconfiguration unfortunately. Even more unfortunate is the fact that we can't change the TC, which is reserved for PTP, because TC2 is hardcoded in firmware.
We would prefer to keep things as is for now, if possible. We'll discuss this with HW/FW team(s) and submit a follow-up patch, if we find a way to automatically choose the config.
Best regards,
Mark.
Jakub Kicinski
maintainerRe: [EXT] Re: [PATCH net-next 03/12] net: atlantic: changes for multi-TC support
Quoted 27 lines · On Thu, 21 May 2020 09:18:44 +0000 Mark Starovoytov wrote:
Hi Jakub,
Quoted 11 lines
Quoted 6 lines
In the first generation of our hardware (A1), a whole traffic class is consumed for PTP handling in FW (FW uses it to send the ptp data and to send back timestamps).
Since this conflicts with QoS (user is unable to use the reserved TC2), we suggest using module param to give the user a choice:
disabling PTP allows using all available TCs.Is there really no way to get the config automatically chosen when user sets up TCs or does SIOCSHWTSTAMP? It's fine to return
-EOPNOTSUPPwhen too many things are enabled, but user having to set module parameters upfront is quite painful.Module param is not a must have for usage, default config allows the user to use TCs and PTP features simultaneously with one major
limitation: TC2 is reserved for PTP, so if the user tries to send/receive anything on TC2, if won't quite work unfortunately. If the user wants to get "everything" from QoS/TC (e.g. use all the TCs)
- he can explicitly disable the PTP via module param.Right now we really aren't sure we can dynamically rearrange resources between QoS and PTP, since disabling/enabling PTP requires a complete HW reconfiguration unfortunately. Even more unfortunate is the fact that we can't change the TC, which is reserved for PTP, because TC2 is hardcoded in firmware.
Quoted 3 lines
We would prefer to keep things as is for now, if possible. We'll discuss this with HW/FW team(s) and submit a follow-up patch, if we find a way to automatically choose the config.
Module parameters are very strongly discouraged for networking drivers. They also constitute uAPI, and can't be changed, short-term solution like that is really far from ideal.
Re: [EXT] Re: [PATCH net-next 03/12] net: atlantic: changes for multi-TC support
Quoted 7 lines
Quoted 7 lines
Right now we really aren't sure we can dynamically rearrange resources between QoS and PTP, since disabling/enabling PTP requires a complete HW reconfiguration unfortunately. Even more unfortunate is the fact that we can't change the TC, which is reserved for PTP, because TC2 is hardcoded in firmware.
Quoted 7 lines
Quoted 3 lines
We would prefer to keep things as is for now, if possible. We'll discuss this with HW/FW team(s) and submit a follow-up patch, if we find a way to automatically choose the config.
Module parameters are very strongly discouraged for networking drivers. They also constitute uAPI, and can't be changed, short-term solution like that is really far from ideal.
Thanks, Jakub.
Mark, Dmitry, lets try eliminating this parameter. Even if that'll cause some limitations now - we can think how to dynamically handle these in future.
Regards,
Igor
David Miller
maintainerRe: [EXT] Re: [PATCH net-next 03/12] net: atlantic: changes for multi-TC support
In reply to Jakub KicinskiFrom: Jakub Kicinski <[email protected]>
Date: Thu, 21 May 2020 12:11:56 -0700
Quoted 1 line
Module parameters are very strongly discouraged for networking drivers.
I fundamentally will disallow them except in very narrowly scoped cases.
Make a real API in the kernel for what you are trying to do, or you can't support the facility in your driver, period.
kbuild test robot
build botRe: [PATCH net-next 03/12] net: atlantic: changes for multi-TC support
In reply to Igor RusskikhThank you for the patch! Perhaps something to improve:
Hi Igor,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
[also build test WARNING on next-20200519]
[cannot apply to net/master linus/master ipvs/master v5.7-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Igor-Russkikh/net-atlantic-QoS-implementation/20200521-033933 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 4f65e2f483b6f764c15094d14dd53dda048a4048 config: alpha-allyesconfig (attached as .config) compiler: alpha-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=alpha
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>, old ones prefixed by <<):
>> drivers/net/ethernet/aquantia/atlantic/aq_ptp.c:951:14: warning: no previous prototype for 'ptp_ring_idx' [-Wmissing-prototypes]
951 | unsigned int ptp_ring_idx(const enum aq_tc_mode tc_mode)
| ^~~~~~~~~~~~
vim +/ptp_ring_idx +951 drivers/net/ethernet/aquantia/atlantic/aq_ptp.c
947
948 /* Index must be 8 (8 TCs) or 16 (4 TCs).
949 * It depends on Traffic Class mode.
950 */
> 951 unsigned int ptp_ring_idx(const enum aq_tc_mode tc_mode)
952 {
953 if (tc_mode == AQ_TC_MODE_8TCS)
954 return PTP_8TC_RING_IDX;
955
956 return PTP_4TC_RING_IDX;
957 }
958
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kbuild test robot
build botRe: [PATCH net-next 03/12] net: atlantic: changes for multi-TC support
In reply to Igor RusskikhThank you for the patch! Perhaps something to improve:
Hi Igor,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
[also build test WARNING on next-20200519]
[cannot apply to net/master linus/master ipvs/master v5.7-rc6]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Igor-Russkikh/net-atlantic-QoS-implementation/20200521-033933 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 4f65e2f483b6f764c15094d14dd53dda048a4048 config: x86_64-allmodconfig (attached as .config) compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0 reproduce: # apt-get install sparse # sparse version: v0.6.1-193-gb8fad4bc-dirty # save the attached .config to linux build tree make C=1 ARCH=x86_64 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'
If you fix the issue, kindly add following tag as appropriate
sparse warnings: (new ones prefixed by >>)
>> drivers/net/ethernet/aquantia/atlantic/aq_ptp.c:951:14: sparse: sparse: symbol 'ptp_ring_idx' was not declared. Should it be static?
Please review and possibly fold the followup patch.
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kbuild test robot
build bot[RFC PATCH] net: atlantic: ptp_ring_idx() can be static
In reply to Igor RusskikhSigned-off-by: kbuild test robot <[email protected]>
--- aq_ptp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/aquantia/atlantic/aq_ptp.c +1 -1
@@ -948,7 +948,7 @@ void aq_ptp_ring_deinit(struct aq_nic_s *aq_nic)/* Index must be 8 (8 TCs) or 16 (4 TCs). * It depends on Traffic Class mode. */ -unsigned int ptp_ring_idx (const enum aq_tc_mode tc_mode) +static unsigned int ptp_ring_idx (const enum aq_tc_mode tc_mode) {if (tc_mode ==AQ_TC_MODE_8TCS )return PTP_8TC_RING_IDX ;
PATCH 4/12 net: atlantic: QoS implementation: multi-TC support
In reply to Igor RusskikhFrom: Dmitry Bezrukov <[email protected]>
This patch adds multi-TC support.
--- .../ethernet/aquantia/atlantic/aq_filters.c | 11 +- .../net/ethernet/aquantia/atlantic/aq_hw.h | 1 + .../ethernet/aquantia/atlantic/aq_hw_utils.c | 26 ++++ .../ethernet/aquantia/atlantic/aq_hw_utils.h | 2 + .../net/ethernet/aquantia/atlantic/aq_main.c | 39 +++++- .../net/ethernet/aquantia/atlantic/aq_nic.c | 58 ++++++++- .../net/ethernet/aquantia/atlantic/aq_nic.h | 14 +- .../net/ethernet/aquantia/atlantic/aq_ring.c | 19 ++- .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 74 ++++++----- .../aquantia/atlantic/hw_atl/hw_atl_llh.c | 9 +- .../aquantia/atlantic/hw_atl2/hw_atl2.c | 122 ++++++++++-------- .../atlantic/hw_atl2/hw_atl2_internal.h | 7 - .../aquantia/atlantic/hw_atl2/hw_atl2_llh.c | 8 ++ .../aquantia/atlantic/hw_atl2/hw_atl2_llh.h | 4 + .../atlantic/hw_atl2/hw_atl2_llh_internal.h | 10 ++ 15 files changed, 290 insertions(+), 114 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_filters.c +7 -4
@@ -153,6 +153,8 @@ aq_check_approve_fvlan(struct aq_nic_s *aq_nic,struct aq_hw_rx_fltrs_s *rx_fltrs, struct ethtool_rx_flow_spec *fsp) { + struct aq_nic_cfg_s *cfg = &aq_nic->aq_nic_cfg; +if (fsp->location <AQ_RX_FIRST_LOC_FVLANID || fsp->location >AQ_RX_LAST_LOC_FVLANID ) { netdev_err(aq_nic->ndev,
@@ -170,10 +172,10 @@ aq_check_approve_fvlan(struct aq_nic_s *aq_nic,return -EINVAL ; } -if (fsp->ring_cookie > aq_nic->aq_nic_cfg.num_rss_queues) { +if (fsp->ring_cookie > cfg->num_rss_queues * cfg->tcs) {netdev_err (aq_nic->ndev,"ethtool: queue number must be in range [0, %d]" , - aq_nic->aq_nic_cfg.num_rss_queues -1 ); + cfg->num_rss_queues * cfg->tcs -1 );return -EINVAL ; }return 0 ;
@@ -262,6 +264,7 @@ static bool __must_check aq_rule_is_not_correct(struct aq_nic_s *aq_nic, struct ethtool_rx_flow_spec *fsp) { + struct aq_nic_cfg_s *cfg = &aq_nic->aq_nic_cfg;bool rule_is_not_correct = false;if (!aq_nic) {
@@ -274,11 +277,11 @@ aq_rule_is_not_correct(struct aq_nic_s *aq_nic, }else if (aq_check_filter (aq_nic, fsp)) { rule_is_not_correct = true; }else if (fsp->ring_cookie !=RX_CLS_FLOW_DISC ) { -if (fsp->ring_cookie >= aq_nic->aq_nic_cfg.num_rss_queues) { +if (fsp->ring_cookie >= cfg->num_rss_queues * cfg->tcs) {netdev_err (aq_nic->ndev,"ethtool: The specified action is invalid.\n" "Maximum allowable value action is %u.\n" , - aq_nic->aq_nic_cfg.num_rss_queues -1 ); + cfg->num_rss_queues * cfg->tcs -1 ); rule_is_not_correct = true; } }
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +1 -0
@@ -124,6 +124,7 @@ struct aq_stats_s {#define AQ_HW_TXD_MULTIPLE 8U#define AQ_HW_RXD_MULTIPLE 8U +#define AQ_HW_QUEUES_MAX 32U#define AQ_HW_MULTICAST_ADDRESS_MAX 32U#define AQ_HW_PTP_TC 2U
drivers/net/ethernet/aquantia/atlantic/aq_hw_utils.c +26 -0
@@ -79,3 +79,29 @@ int aq_hw_err_from_flags(struct aq_hw_s *hw) err_exit:return err; } + +int aq_hw_num_tcs (struct aq_hw_s *hw) +{ +switch (hw->aq_nic_cfg->tc_mode) { +case AQ_TC_MODE_8TCS : +return 8 ; +case AQ_TC_MODE_4TCS : +return 4 ; +default : +break ; + } + +return 1 ; +} + +int aq_hw_q_per_tc (struct aq_hw_s *hw) +{ +switch (hw->aq_nic_cfg->tc_mode) { +case AQ_TC_MODE_8TCS : +return 4 ; +case AQ_TC_MODE_4TCS : +return 8 ; +default : +return 4 ; + } +}
drivers/net/ethernet/aquantia/atlantic/aq_hw_utils.h +2 -0
@@ -34,5 +34,7 @@ u32 aq_hw_read_reg(struct aq_hw_s *hw, u32 reg);void aq_hw_write_reg (struct aq_hw_s *hw,u32 reg,u32 value);u64 aq_hw_read_reg64 (struct aq_hw_s *hw,u32 reg);int aq_hw_err_from_flags (struct aq_hw_s *hw); +int aq_hw_num_tcs (struct aq_hw_s *hw); +int aq_hw_q_per_tc (struct aq_hw_s *hw);#endif /* AQ_HW_UTILS_H */
drivers/net/ethernet/aquantia/atlantic/aq_main.c +38 -1
@@ -12,11 +12,13 @@#include "aq_ethtool.h" #include "aq_ptp.h" #include "aq_filters.h" +#include "aq_hw_utils.h" #include <linux/netdevice.h> #include <linux/module.h> #include <linux/ip.h> #include <linux/udp.h> +#include <net/pkt_cls.h> MODULE_LICENSE ("GPL v2" );MODULE_AUTHOR (AQ_CFG_DRV_AUTHOR );
@@ -38,7 +40,7 @@ struct net_device *aq_ndev_alloc(void)struct net_device *ndev =NULL ;struct aq_nic_s *aq_nic =NULL ; - ndev =alloc_etherdev_mq (sizeof (struct aq_nic_s ),AQ_CFG_VECS_MAX ); + ndev =alloc_etherdev_mq (sizeof (struct aq_nic_s ),AQ_HW_QUEUES_MAX );if (!ndev)return NULL ;
@@ -330,6 +332,40 @@ static int aq_ndo_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto,return 0 ; } +static int aq_validate_mqprio_opt (struct aq_nic_s *self, +const unsigned int num_tc) +{ +if (num_tc >aq_hw_num_tcs (self->aq_hw)) { +netdev_err (self->ndev,"Too many TCs requested\n" ); +return -EOPNOTSUPP ; + } + +if (num_tc !=0 && !is_power_of_2 (num_tc)) { +netdev_err (self->ndev,"TC count should be power of 2\n" ); +return -EOPNOTSUPP ; + } + +return 0 ; +} + +static int aq_ndo_setup_tc (struct net_device *dev,enum tc_setup_type type, +void *type_data) +{ +struct aq_nic_s *aq_nic =netdev_priv (dev); +struct tc_mqprio_qopt *mqprio = type_data; +int err; + +if (type !=TC_SETUP_QDISC_MQPRIO ) +return -EOPNOTSUPP ; + + err =aq_validate_mqprio_opt (aq_nic, mqprio->num_tc); +if (err) +return err; + +return aq_nic_setup_tc_mqprio (aq_nic, mqprio->num_tc, + mqprio->prio_tc_map); +} +static const struct net_device_ops aq_ndev_ops = { .ndo_open = aq_ndev_open, .ndo_stop = aq_ndev_close,
@@ -341,6 +377,7 @@ static const struct net_device_ops aq_ndev_ops = { .ndo_do_ioctl = aq_ndev_ioctl, .ndo_vlan_rx_add_vid = aq_ndo_vlan_rx_add_vid, .ndo_vlan_rx_kill_vid = aq_ndo_vlan_rx_kill_vid, + .ndo_setup_tc = aq_ndo_setup_tc, };static int __init aq_ndev_init_module (void )
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +54 -4
106 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/aq_nic.h +12 -2
@@ -59,10 +59,12 @@ struct aq_nic_cfg_s {bool is_polling;bool is_rss;bool is_lro; +bool is_qos;bool is_ptp;enum aq_tc_mode tc_mode;u32 priv_flags;u8 tcs; +u8 prio_tc_map[8 ];struct aq_rss_parameters aq_rss;u32 eee_speeds; };
@@ -79,8 +81,15 @@ struct aq_nic_cfg_s {#define AQ_NIC_WOL_MODES (WAKE_MAGIC |\ WAKE_PHY) +#define AQ_NIC_RING_PER_TC (_NIC_) \ + (((_NIC_)->aq_nic_cfg.tc_mode == AQ_TC_MODE_4TCS) ? 8 : 4) +#define AQ_NIC_TCVEC2RING (_NIC_, _TC_, _VEC_) \ - ((_TC_) * AQ_CFG_TCS_MAX + (_VEC_)) + ((_TC_) * AQ_NIC_RING_PER_TC(_NIC_) + (_VEC_)) + +#define AQ_NIC_RING2QMAP (_NIC_, _ID_) \ + ((_ID_) / AQ_NIC_RING_PER_TC(_NIC_) * (_NIC_)->aq_vecs + \ + ((_ID_) % AQ_NIC_RING_PER_TC(_NIC_)))struct aq_hw_rx_fl2 {struct aq_rx_filter_vlan aq_vlans[AQ_VLAN_MAX_FILTERS ];
@@ -106,7 +115,7 @@ struct aq_nic_s {atomic_t flags;u32 msg_enable;struct aq_vec_s *aq_vec[AQ_CFG_VECS_MAX ]; -struct aq_ring_s *aq_ring_tx[AQ_CFG_VECS_MAX *AQ_CFG_TCS_MAX ]; +struct aq_ring_s *aq_ring_tx[AQ_HW_QUEUES_MAX ];struct aq_hw_s *aq_hw;struct net_device *ndev;unsigned int aq_vecs;
@@ -183,4 +192,5 @@ void aq_nic_shutdown(struct aq_nic_s *self);u8 aq_nic_reserve_filter (struct aq_nic_s *self,enum aq_rx_filter_type type);void aq_nic_release_filter (struct aq_nic_s *self,enum aq_rx_filter_type type,u32 location); +int aq_nic_setup_tc_mqprio (struct aq_nic_s *self,u32 tcs,u8 *prio_tc_map);#endif /* AQ_NIC_H */
drivers/net/ethernet/aquantia/atlantic/aq_ring.c +14 -5
@@ -232,8 +232,11 @@ void aq_ring_queue_wake(struct aq_ring_s *ring) {struct net_device *ndev =aq_nic_get_ndev (ring->aq_nic); -if (__netif_subqueue_stopped (ndev, ring->idx)) { -netif_wake_subqueue (ndev, ring->idx); +if (__netif_subqueue_stopped (ndev, +AQ_NIC_RING2QMAP (ring->aq_nic, + ring->idx))) { +netif_wake_subqueue (ndev, +AQ_NIC_RING2QMAP (ring->aq_nic, ring->idx)); ring->stats.tx.queue_restarts++; } }
@@ -242,8 +245,11 @@ void aq_ring_queue_stop(struct aq_ring_s *ring) {struct net_device *ndev =aq_nic_get_ndev (ring->aq_nic); -if (!__netif_subqueue_stopped (ndev, ring->idx)) -netif_stop_subqueue (ndev, ring->idx); +if (!__netif_subqueue_stopped (ndev, +AQ_NIC_RING2QMAP (ring->aq_nic, + ring->idx))) +netif_stop_subqueue (ndev, +AQ_NIC_RING2QMAP (ring->aq_nic, ring->idx)); }bool aq_ring_tx_clean (struct aq_ring_s *self)
@@ -466,7 +472,10 @@ int aq_ring_rx_clean(struct aq_ring_s *self, buff->is_hash_l4 ?PKT_HASH_TYPE_L4 : PKT_HASH_TYPE_NONE);/* Send all PTP traffic to 0 queue */ -skb_record_rx_queue (skb, is_ptp_ring ?0 : self->idx); +skb_record_rx_queue (skb, + is_ptp_ring ?0 + :AQ_NIC_RING2QMAP (self->aq_nic, + self->idx)); ++self->stats.rx.packets; self->stats.rx.bytes += skb->len;
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +39 -35
109 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c +4 -5
@@ -754,7 +754,7 @@ void hw_atl_rpfl2_accept_all_mc_packets_set(struct aq_hw_s *aq_hw, }void hw_atl_rpf_rpb_user_priority_tc_map_set (struct aq_hw_s *aq_hw, -u32 user_priority_tc_map,u32 tc) +u32 user_priority,u32 tc) {/* register address for bitfield rx_tc_up{t}[2:0] */ static u32 rpf_rpb_rx_tc_upt_adr[8 ] = {
@@ -773,10 +773,9 @@ void hw_atl_rpf_rpb_user_priority_tc_map_set(struct aq_hw_s *aq_hw, 0U, 4U, 8U, 12U, 16U, 20U, 24U, 28U }; -aq_hw_write_reg_bit (aq_hw, rpf_rpb_rx_tc_upt_adr[tc], - rpf_rpb_rx_tc_upt_msk[tc], - rpf_rpb_rx_tc_upt_shft[tc], - user_priority_tc_map); +aq_hw_write_reg_bit (aq_hw, rpf_rpb_rx_tc_upt_adr[user_priority], + rpf_rpb_rx_tc_upt_msk[user_priority], + rpf_rpb_rx_tc_upt_shft[user_priority], tc); }void hw_atl_rpf_rss_key_addr_set (struct aq_hw_s *aq_hw,u32 rss_key_addr)
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +71 -51
190 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h +0 -7
@@ -82,13 +82,6 @@ enum HW_ATL2_RPF_ART_INDEX {HW_ATL2_RPF_VLAN_USER_INDEX =HW_ATL2_RPF_ET_PCP_USER_INDEX +16 ,HW_ATL2_RPF_PCP_TO_TC_INDEX =HW_ATL2_RPF_VLAN_USER_INDEX + HW_ATL_VLAN_MAX_FILTERS, -HW_ATL2_RPF_VLAN_INDEX =HW_ATL2_RPF_PCP_TO_TC_INDEX + -AQ_CFG_TCS_MAX , -HW_ATL2_RPF_MAC_INDEX , -HW_ATL2_RPF_ALLMC_INDEX , -HW_ATL2_RPF_UNTAG_INDEX , -HW_ATL2_RPF_VLAN_PROMISC_ON_INDEX , - HW_ATL2_RPF_L2_PROMISC_ON_INDEX, };#define HW_ATL2_ACTION (ACTION ,RSS ,INDEX ,VALID ) \
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh.c +8 -0
@@ -7,6 +7,14 @@#include "hw_atl2_llh_internal.h" #include "aq_hw_utils.h" +void hw_atl2_rpf_redirection_table2_select_set (struct aq_hw_s *aq_hw, +u32 select) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_RPF_PIF_RPF_REDIR2_ENI_ADR , +HW_ATL2_RPF_PIF_RPF_REDIR2_ENI_MSK , +HW_ATL2_RPF_PIF_RPF_REDIR2_ENI_SHIFT , select); +} +void hw_atl2_rpf_rss_hash_type_set (struct aq_hw_s *aq_hw,u32 rss_hash_type) { aq_hw_write_reg_bit(aq_hw, HW_ATL2_RPF_PIF_RPF_RSS_HASH_TYPEI_ADR,
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh.h +4 -0
@@ -15,6 +15,10 @@ void hw_atl2_reg_tx_intr_moder_ctrl_set(struct aq_hw_s *aq_hw,u32 tx_intr_moderation_ctl, u32 queue); +/* Set Redirection Table 2 Select */ +void hw_atl2_rpf_redirection_table2_select_set (struct aq_hw_s *aq_hw, +u32 select); +/** Set RSS HASH type */ void hw_atl2_rpf_rss_hash_type_set (struct aq_hw_s *aq_hw,u32 rss_hash_type);
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh_internal.h +10 -0
@@ -6,6 +6,16 @@#ifndef HW_ATL2_LLH_INTERNAL_H #define HW_ATL2_LLH_INTERNAL_H +/* RX pif_rpf_redir_2_en_i Bitfield Definitions +* PORT="pif_rpf_redir_2_en_i" +*/ +#define HW_ATL2_RPF_PIF_RPF_REDIR2_ENI_ADR 0x000054C8 +#define HW_ATL2_RPF_PIF_RPF_REDIR2_ENI_MSK 0x00001000 +#define HW_ATL2_RPF_PIF_RPF_REDIR2_ENI_MSKN 0xFFFFEFFF +#define HW_ATL2_RPF_PIF_RPF_REDIR2_ENI_SHIFT 12 +#define HW_ATL2_RPF_PIF_RPF_REDIR2_ENI_WIDTH 1 +#define HW_ATL2_RPF_PIF_RPF_REDIR2_ENI_DEFAULT 0x0 +/* RX pif_rpf_rss_hash_type_i Bitfield Definitions */ #define HW_ATL2_RPF_PIF_RPF_RSS_HASH_TYPEI_ADR 0x000054C8
Signature · 1 line
2.25.1
PATCH 5/12 net: atlantic: per-TC queue statistics
In reply to Igor RusskikhFrom: Mark Starovoytov <[email protected]>
This patch adds support for per-TC queue statistics.
By default (single TC), the output is the same as it used to be, e.g.:
Queue[0] InPackets: 2
Queue[0] OutPackets: 8
Queue[0] Restarts: 0
Queue[0] InJumboPackets: 0
Queue[0] InLroPackets: 0
Queue[0] InErrors: 0
If several TCs are enabled, then each queue statistics line is prefixed with TC number, e.g.:
TC0 Queue[0] InPackets: 6
TC0 Queue[0] OutPackets: 11
Queue numbering is end-to-end, so:
TC1 Queue[4] InPackets: 0
TC1 Queue[4] OutPackets: 22
--- .../ethernet/aquantia/atlantic/aq_ethtool.c | 59 +++++++++++-------- .../net/ethernet/aquantia/atlantic/aq_nic.c | 12 ++-- .../net/ethernet/aquantia/atlantic/aq_vec.c | 24 ++++---- .../net/ethernet/aquantia/atlantic/aq_vec.h | 5 +- 4 files changed, 59 insertions(+), 41 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +36 -23
@@ -88,13 +88,13 @@ static const char aq_ethtool_stat_names[][ETH_GSTRING_LEN] = { "InDroppedDma", }; -static const char aq_ethtool_queue_stat_names[][ETH_GSTRING_LEN ] = { -"Queue[%d] InPackets" , -"Queue[%d] OutPackets" , -"Queue[%d] Restarts" , -"Queue[%d] InJumboPackets" , -"Queue[%d] InLroPackets" , -"Queue[%d] InErrors" , +static const char *const aq_ethtool_queue_stat_names[] = { +"%sQueue[%d] InPackets" , +"%sQueue[%d] OutPackets" , +"%sQueue[%d] Restarts" , +"%sQueue[%d] InJumboPackets" , +"%sQueue[%d] InLroPackets" , +"%sQueue[%d] InErrors" , };#if IS_ENABLED (CONFIG_MACSEC )
@@ -166,7 +166,8 @@ static u32 aq_ethtool_n_stats(struct net_device *ndev)struct aq_nic_s *nic =netdev_priv (ndev);struct aq_nic_cfg_s *cfg =aq_nic_get_cfg (nic);u32 n_stats =ARRAY_SIZE (aq_ethtool_stat_names) + -ARRAY_SIZE (aq_ethtool_queue_stat_names) * cfg->vecs; +ARRAY_SIZE (aq_ethtool_queue_stat_names) * cfg->vecs * + cfg->tcs;#if IS_ENABLED (CONFIG_MACSEC )if (nic->macsec_cfg) {
@@ -223,7 +224,7 @@ static void aq_ethtool_get_drvinfo(struct net_device *ndev,static void aq_ethtool_get_strings (struct net_device *ndev,u32 stringset,u8 *data) { -struct aq_nic_s *aq_nic =netdev_priv (ndev); +struct aq_nic_s *nic =netdev_priv (ndev);struct aq_nic_cfg_s *cfg;u8 *p = data;int i, si;
@@ -231,24 +232,35 @@ static void aq_ethtool_get_strings(struct net_device *ndev,int sa;#endif - cfg =aq_nic_get_cfg (aq_nic); + cfg =aq_nic_get_cfg (nic);switch (stringset) { -case ETH_SS_STATS : +case ETH_SS_STATS : { +const int stat_cnt =ARRAY_SIZE (aq_ethtool_queue_stat_names); +char tc_string[8 ]; +int tc; + +memset (tc_string,0 ,sizeof (tc_string));memcpy (p, aq_ethtool_stat_names,sizeof (aq_ethtool_stat_names)); p = p +sizeof (aq_ethtool_stat_names); -for (i =0 ; i < cfg->vecs; i++) { -for (si =0 ; - si <ARRAY_SIZE (aq_ethtool_queue_stat_names); - si++) { -snprintf (p,ETH_GSTRING_LEN , - aq_ethtool_queue_stat_names[si], i); - p +=ETH_GSTRING_LEN ; + +for (tc =0 ; tc < cfg->tcs; tc++) { +if (cfg->is_qos) +snprintf (tc_string,8 ,"TC%d " , tc); + +for (i =0 ; i < cfg->vecs; i++) { +for (si =0 ; si < stat_cnt; si++) { +snprintf (p,ETH_GSTRING_LEN , + aq_ethtool_queue_stat_names[si], + tc_string, +AQ_NIC_TCVEC2RING (nic, tc, i)); + p +=ETH_GSTRING_LEN ; + } } }#if IS_ENABLED (CONFIG_MACSEC ) -if (!aq_nic->macsec_cfg) +if (!nic->macsec_cfg)break ;memcpy (p, aq_macsec_stat_names,sizeof (aq_macsec_stat_names));
@@ -256,7 +268,7 @@ static void aq_ethtool_get_strings(struct net_device *ndev,for (i =0 ; i <AQ_MACSEC_MAX_SC ; i++) {struct aq_macsec_txsc *aq_txsc; -if (!(test_bit (i, &aq_nic->macsec_cfg->txsc_idx_busy))) +if (!(test_bit (i, &nic->macsec_cfg->txsc_idx_busy)))continue ; for (si = 0;
@@ -266,7 +278,7 @@ static void aq_ethtool_get_strings(struct net_device *ndev, aq_macsec_txsc_stat_names[si], i); p +=ETH_GSTRING_LEN ; } - aq_txsc = &aq_nic->macsec_cfg->aq_txsc[i]; + aq_txsc = &nic->macsec_cfg->aq_txsc[i];for (sa =0 ; sa <MACSEC_NUM_AN ; sa++) {if (!(test_bit (sa, &aq_txsc->tx_sa_idx_busy)))continue ;
@@ -283,10 +295,10 @@ static void aq_ethtool_get_strings(struct net_device *ndev,for (i =0 ; i <AQ_MACSEC_MAX_SC ; i++) {struct aq_macsec_rxsc *aq_rxsc; -if (!(test_bit (i, &aq_nic->macsec_cfg->rxsc_idx_busy))) +if (!(test_bit (i, &nic->macsec_cfg->rxsc_idx_busy)))continue ; - aq_rxsc = &aq_nic->macsec_cfg->aq_rxsc[i]; + aq_rxsc = &nic->macsec_cfg->aq_rxsc[i];for (sa =0 ; sa <MACSEC_NUM_AN ; sa++) {if (!(test_bit (sa, &aq_rxsc->rx_sa_idx_busy)))continue ;
@@ -302,6 +314,7 @@ static void aq_ethtool_get_strings(struct net_device *ndev, }#endif break ; + }case ETH_SS_PRIV_FLAGS :memcpy (p, aq_ethtool_priv_flag_names,sizeof (aq_ethtool_priv_flag_names));
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +8 -4
@@ -859,6 +859,7 @@ u64 *aq_nic_get_stats(struct aq_nic_s *self, u64 *data)struct aq_stats_s *stats;unsigned int count =0U ;unsigned int i =0U ; +unsigned int tc;if (self->aq_fw_ops->update_stats) {mutex_lock (&self->fwreq_mutex);
@@ -897,10 +898,13 @@ u64 *aq_nic_get_stats(struct aq_nic_s *self, u64 *data) data += i; -for (i =0U , aq_vec = self->aq_vec[0 ]; - aq_vec && self->aq_vecs > i; ++i, aq_vec = self->aq_vec[i]) { - data += count; -aq_vec_get_sw_stats (aq_vec, data, &count); +for (tc =0U ; tc < self->aq_nic_cfg.tcs; tc++) { +for (i =0U , aq_vec = self->aq_vec[0 ]; + aq_vec && self->aq_vecs > i; + ++i, aq_vec = self->aq_vec[i]) { + data += count; +aq_vec_get_sw_stats (aq_vec, tc, data, &count); + } } data += count;
drivers/net/ethernet/aquantia/atlantic/aq_vec.c +14 -10
@@ -348,16 +348,14 @@ cpumask_t *aq_vec_get_affinity_mask(struct aq_vec_s *self)return &self->aq_ring_param.affinity_mask; } -void aq_vec_add_stats (struct aq_vec_s *self, -struct aq_ring_stats_rx_s *stats_rx, -struct aq_ring_stats_tx_s *stats_tx) +static void aq_vec_add_stats (struct aq_vec_s *self, +const unsigned int tc, +struct aq_ring_stats_rx_s *stats_rx, +struct aq_ring_stats_tx_s *stats_tx) { -struct aq_ring_s *ring =NULL ; -unsigned int r =0U ; +struct aq_ring_s *ring = self->ring[tc]; -for (r =0U , ring = self->ring[0 ]; - self->tx_rings > r; ++r, ring = self->ring[r]) { -struct aq_ring_stats_tx_s *tx = &ring[AQ_VEC_TX_ID ].stats.tx; +if (tc < self->rx_rings) {struct aq_ring_stats_rx_s *rx = &ring[AQ_VEC_RX_ID ].stats.rx; stats_rx->packets += rx->packets;
@@ -368,6 +366,10 @@ void aq_vec_add_stats(struct aq_vec_s *self, stats_rx->pg_losts += rx->pg_losts; stats_rx->pg_flips += rx->pg_flips; stats_rx->pg_reuses += rx->pg_reuses; + } + +if (tc < self->tx_rings) { +struct aq_ring_stats_tx_s *tx = &ring[AQ_VEC_TX_ID ].stats.tx; stats_tx->packets += tx->packets; stats_tx->bytes += tx->bytes;
@@ -376,7 +378,8 @@ void aq_vec_add_stats(struct aq_vec_s *self, } } -int aq_vec_get_sw_stats (struct aq_vec_s *self,u64 *data,unsigned int *p_count) +int aq_vec_get_sw_stats (struct aq_vec_s *self,const unsigned int tc,u64 *data, +unsigned int *p_count) {struct aq_ring_stats_rx_s stats_rx;struct aq_ring_stats_tx_s stats_tx;
@@ -384,7 +387,8 @@ int aq_vec_get_sw_stats(struct aq_vec_s *self, u64 *data, unsigned int *p_count)memset (&stats_rx,0U ,sizeof (struct aq_ring_stats_rx_s ));memset (&stats_tx,0U ,sizeof (struct aq_ring_stats_tx_s )); -aq_vec_add_stats (self, &stats_rx, &stats_tx); + +aq_vec_add_stats (self, tc, &stats_rx, &stats_tx);/* This data should mimic aq_ethtool_queue_stat_names structure */
drivers/net/ethernet/aquantia/atlantic/aq_vec.h +1 -4
@@ -35,10 +35,7 @@ void aq_vec_ring_free(struct aq_vec_s *self);int aq_vec_start (struct aq_vec_s *self);void aq_vec_stop (struct aq_vec_s *self);cpumask_t *aq_vec_get_affinity_mask (struct aq_vec_s *self); -int aq_vec_get_sw_stats (struct aq_vec_s *self,u64 *data, +int aq_vec_get_sw_stats (struct aq_vec_s *self,const unsigned int tc,u64 *data,unsigned int *p_count); -void aq_vec_add_stats (struct aq_vec_s *self, -struct aq_ring_stats_rx_s *stats_rx, -struct aq_ring_stats_tx_s *stats_tx);#endif /* AQ_VEC_H */
Signature · 1 line
2.25.1
PATCH 6/12 net: atlantic: make TCVEC2RING accept nic_cfg
In reply to Igor RusskikhFrom: Mark Starovoytov <[email protected]>
This patch updates TCVEC2RING to accept nic_cfg, which is needed to be able to use it from hw_atl.
The name is updated to reflect the changes.
--- drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c | 2 +- drivers/net/ethernet/aquantia/atlantic/aq_nic.c | 9 +++++---- drivers/net/ethernet/aquantia/atlantic/aq_nic.h | 13 +++++++------ drivers/net/ethernet/aquantia/atlantic/aq_vec.c | 3 ++- 4 files changed, 15 insertions(+), 12 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +1 -1
@@ -254,7 +254,7 @@ static void aq_ethtool_get_strings(struct net_device *ndev,snprintf (p,ETH_GSTRING_LEN , aq_ethtool_queue_stat_names[si], tc_string, -AQ_NIC_TCVEC2RING (nic, tc, i)); +AQ_NIC_CFG_TCVEC2RING (cfg, tc, i)); p +=ETH_GSTRING_LEN ; } }
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +5 -4
@@ -705,15 +705,16 @@ unsigned int aq_nic_map_skb(struct aq_nic_s *self, struct sk_buff *skb,int aq_nic_xmit (struct aq_nic_s *self,struct sk_buff *skb) { -unsigned int vec = skb->queue_mapping % self->aq_nic_cfg.vecs; -unsigned int tc = skb->queue_mapping / self->aq_nic_cfg.vecs; +struct aq_nic_cfg_s *cfg =aq_nic_get_cfg (self); +unsigned int vec = skb->queue_mapping % cfg->vecs; +unsigned int tc = skb->queue_mapping / cfg->vecs;struct aq_ring_s *ring =NULL ;unsigned int frags =0U ;int err =NETDEV_TX_OK ; frags =skb_shinfo (skb)->nr_frags +1 ; - ring = self->aq_ring_tx[AQ_NIC_TCVEC2RING (self, tc, vec)]; + ring = self->aq_ring_tx[AQ_NIC_CFG_TCVEC2RING (cfg, tc, vec)];if (frags >AQ_CFG_SKB_FRAGS_MAX ) {dev_kfree_skb_any (skb);
@@ -722,7 +723,7 @@ int aq_nic_xmit(struct aq_nic_s *self, struct sk_buff *skb)aq_ring_update_queue_state (ring); -if (self->aq_nic_cfg.priv_flags &BIT (AQ_HW_LOOPBACK_DMA_NET )) { +if (cfg->priv_flags &BIT (AQ_HW_LOOPBACK_DMA_NET )) { err =NETDEV_TX_BUSY ; goto err_exit; }
drivers/net/ethernet/aquantia/atlantic/aq_nic.h +7 -6
@@ -81,15 +81,16 @@ struct aq_nic_cfg_s {#define AQ_NIC_WOL_MODES (WAKE_MAGIC |\ WAKE_PHY) -#define AQ_NIC_RING_PER_TC (_NIC_) \ - (((_NIC_)->aq_nic_cfg.tc_mode == AQ_TC_MODE_4TCS) ? 8 : 4) +#define AQ_NIC_CFG_RING_PER_TC (_NIC_CFG_) \ + (((_NIC_CFG_)->tc_mode == AQ_TC_MODE_4TCS) ? 8 : 4) -#define AQ_NIC_TCVEC2RING (_NIC_, _TC_, _VEC_) \ - ((_TC_) * AQ_NIC_RING_PER_TC(_NIC_) + (_VEC_)) +#define AQ_NIC_CFG_TCVEC2RING (_NIC_CFG_, _TC_, _VEC_) \ + ((_TC_) * AQ_NIC_CFG_RING_PER_TC(_NIC_CFG_) + (_VEC_))#define AQ_NIC_RING2QMAP (_NIC_, _ID_) \ - ((_ID_) / AQ_NIC_RING_PER_TC(_NIC_) * (_NIC_)->aq_vecs + \ - ((_ID_) % AQ_NIC_RING_PER_TC(_NIC_))) + ((_ID_) / AQ_NIC_CFG_RING_PER_TC(&(_NIC_)->aq_nic_cfg) * \ + (_NIC_)->aq_vecs + \ + ((_ID_) % AQ_NIC_CFG_RING_PER_TC(&(_NIC_)->aq_nic_cfg)))struct aq_hw_rx_fl2 {struct aq_rx_filter_vlan aq_vlans[AQ_VLAN_MAX_FILTERS ];
drivers/net/ethernet/aquantia/atlantic/aq_vec.c +2 -1
@@ -135,7 +135,8 @@ int aq_vec_ring_alloc(struct aq_vec_s *self, struct aq_nic_s *aq_nic,int err =0 ;for (i =0 ; i < aq_nic_cfg->tcs; ++i) { -unsigned int idx_ring =AQ_NIC_TCVEC2RING (aq_nic, i, idx); +const unsigned int idx_ring =AQ_NIC_CFG_TCVEC2RING (aq_nic_cfg, + i, idx); ring =aq_ring_tx_alloc (&self->ring[i][AQ_VEC_TX_ID ], aq_nic, idx_ring, aq_nic_cfg);
Signature · 1 line
2.25.1
PATCH 7/12 net: atlantic: QoS implementation: max_rate
In reply to Igor RusskikhFrom: Mark Starovoytov <[email protected]>
This patch adds initial support for mqprio rate limiters (max_rate only).
Atlantic HW supports Rate-Shaping for time-sensitive traffic at per Traffic Class (TC) granularity.
Target rate is defined by:
* nominal link rate (always 10G);
* rate factor (ratio between nominal rate and max allowed).
--- .../net/ethernet/aquantia/atlantic/aq_hw.h | 3 + .../net/ethernet/aquantia/atlantic/aq_main.c | 35 ++++++++-- .../net/ethernet/aquantia/atlantic/aq_nic.c | 20 ++++++ .../net/ethernet/aquantia/atlantic/aq_nic.h | 3 + .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 58 +++++++++++++-- .../aquantia/atlantic/hw_atl/hw_atl_b0.h | 2 + .../aquantia/atlantic/hw_atl/hw_atl_llh.c | 36 ++++++++++ .../aquantia/atlantic/hw_atl/hw_atl_llh.h | 16 +++++ .../atlantic/hw_atl/hw_atl_llh_internal.h | 70 +++++++++++++++++++ .../aquantia/atlantic/hw_atl2/hw_atl2.c | 9 +-- 10 files changed, 240 insertions(+), 12 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +3 -0
@@ -35,6 +35,9 @@ enum aq_tc_mode { (AQ_RX_LAST_LOC_FVLANID - AQ_RX_FIRST_LOC_FVLANID + 1U)#define AQ_RX_QUEUE_NOT_ASSIGNED 0xFFU +/* Used for rate to Mbps conversion */ +#define AQ_MBPS_DIVISOR 125000/* 1000000 / 8 */ +/* NIC H/W capabilities */ struct aq_hw_caps_s {u64 hw_features;
drivers/net/ethernet/aquantia/atlantic/aq_main.c +31 -4
@@ -333,8 +333,12 @@ static int aq_ndo_vlan_rx_kill_vid(struct net_device *ndev, __be16 proto, }static int aq_validate_mqprio_opt (struct aq_nic_s *self, +struct tc_mqprio_qopt_offload *mqprio,const unsigned int num_tc) { +const bool has_min_rate = !!(mqprio->flags &TC_MQPRIO_F_MIN_RATE ); +int i; +if (num_tc >aq_hw_num_tcs (self->aq_hw)) {netdev_err (self->ndev,"Too many TCs requested\n" );return -EOPNOTSUPP ;
@@ -345,25 +349,48 @@ static int aq_validate_mqprio_opt(struct aq_nic_s *self,return -EOPNOTSUPP ; } +for (i =0 ; i < num_tc; i++) { +if (has_min_rate && mqprio->min_rate[i]) { +netdev_err (self->ndev, +"Min tx rate is not supported\n" ); +return -EOPNOTSUPP ; + } + } +return 0 ; }static int aq_ndo_setup_tc (struct net_device *dev,enum tc_setup_type type,void *type_data) { +struct tc_mqprio_qopt_offload *mqprio = type_data;struct aq_nic_s *aq_nic =netdev_priv (dev); -struct tc_mqprio_qopt *mqprio = type_data; +bool has_min_rate; +bool has_max_rate;int err; +int i;if (type !=TC_SETUP_QDISC_MQPRIO )return -EOPNOTSUPP ; - err =aq_validate_mqprio_opt (aq_nic, mqprio->num_tc); + has_min_rate = !!(mqprio->flags &TC_MQPRIO_F_MIN_RATE ); + has_max_rate = !!(mqprio->flags &TC_MQPRIO_F_MAX_RATE ); + + err =aq_validate_mqprio_opt (aq_nic, mqprio, mqprio->qopt.num_tc);if (err)return err; -return aq_nic_setup_tc_mqprio (aq_nic, mqprio->num_tc, - mqprio->prio_tc_map); +if (mqprio->flags &TC_MQPRIO_F_MAX_RATE ) { +for (i =0 ; i < mqprio->qopt.num_tc; i++) { +u64 max_rate = mqprio->max_rate[i]; + +do_div (max_rate,AQ_MBPS_DIVISOR ); +aq_nic_setup_tc_max_rate (aq_nic, i, (u32 )max_rate); + } + } + +return aq_nic_setup_tc_mqprio (aq_nic, mqprio->qopt.num_tc, + mqprio->qopt.prio_tc_map); }static const struct net_device_ops aq_ndev_ops = {
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +20 -0
@@ -1325,3 +1325,23 @@ int aq_nic_setup_tc_mqprio(struct aq_nic_s *self, u32 tcs, u8 *prio_tc_map)return err; } + +int aq_nic_setup_tc_max_rate (struct aq_nic_s *self,const unsigned int tc, +const u32 max_rate) +{ +struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; + +if (tc >=AQ_CFG_TCS_MAX ) +return -EINVAL ; + +if (max_rate && max_rate <10 ) { +netdev_warn (self->ndev, +"Setting %s to the minimum usable value of %dMbps.\n" , +"max rate" ,10 ); + cfg->tc_max_rate[tc] =10 ; + }else { + cfg->tc_max_rate[tc] = max_rate; + } + +return 0 ; +}
drivers/net/ethernet/aquantia/atlantic/aq_nic.h +3 -0
@@ -65,6 +65,7 @@ struct aq_nic_cfg_s {u32 priv_flags;u8 tcs;u8 prio_tc_map[8 ]; +u32 tc_max_rate[AQ_CFG_TCS_MAX ];struct aq_rss_parameters aq_rss;u32 eee_speeds; };
@@ -194,4 +195,6 @@ u8 aq_nic_reserve_filter(struct aq_nic_s *self, enum aq_rx_filter_type type);void aq_nic_release_filter (struct aq_nic_s *self,enum aq_rx_filter_type type,u32 location);int aq_nic_setup_tc_mqprio (struct aq_nic_s *self,u32 tcs,u8 *prio_tc_map); +int aq_nic_setup_tc_max_rate (struct aq_nic_s *self,const unsigned int tc, +const u32 max_rate);#endif /* AQ_NIC_H */
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +54 -4
85 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.h +2 -0
@@ -62,6 +62,8 @@ int hw_atl_b0_hw_mac_addr_set(struct aq_hw_s *self, u8 *mac_addr);int hw_atl_b0_hw_start (struct aq_hw_s *self); +int hw_atl_b0_hw_init_tx_tc_rate_limit (struct aq_hw_s *self); +int hw_atl_b0_hw_irq_enable (struct aq_hw_s *self,u64 mask);int hw_atl_b0_hw_irq_disable (struct aq_hw_s *self,u64 mask);int hw_atl_b0_hw_irq_read (struct aq_hw_s *self,u64 *mask);
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c +36 -0
@@ -1511,6 +1511,42 @@ void hw_atl_tps_tx_pkt_shed_tc_data_weight_set(struct aq_hw_s *aq_hw, tx_pkt_shed_tc_data_weight); } +void hw_atl_tps_tx_desc_rate_mode_set (struct aq_hw_s *aq_hw, +const u32 rate_mode) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL_TPS_TX_DESC_RATE_MODE_ADR , +HW_ATL_TPS_TX_DESC_RATE_MODE_MSK , +HW_ATL_TPS_TX_DESC_RATE_MODE_SHIFT , + rate_mode); +} + +void hw_atl_tps_tx_desc_rate_en_set (struct aq_hw_s *aq_hw,const u32 desc, +const u32 enable) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL_TPS_DESC_RATE_EN_ADR (desc), +HW_ATL_TPS_DESC_RATE_EN_MSK , +HW_ATL_TPS_DESC_RATE_EN_SHIFT , + enable); +} + +void hw_atl_tps_tx_desc_rate_x_set (struct aq_hw_s *aq_hw,const u32 desc, +const u32 rate_int) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL_TPS_DESC_RATE_X_ADR (desc), +HW_ATL_TPS_DESC_RATE_X_MSK , +HW_ATL_TPS_DESC_RATE_X_SHIFT , + rate_int); +} + +void hw_atl_tps_tx_desc_rate_y_set (struct aq_hw_s *aq_hw,const u32 desc, +const u32 rate_frac) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL_TPS_DESC_RATE_Y_ADR (desc), +HW_ATL_TPS_DESC_RATE_Y_MSK , +HW_ATL_TPS_DESC_RATE_Y_SHIFT , + rate_frac); +} +/* tx */ void hw_atl_tx_tx_reg_res_dis_set (struct aq_hw_s *aq_hw,u32 tx_reg_res_dis) {
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h +16 -0
@@ -710,6 +710,22 @@ void hw_atl_tps_tx_pkt_shed_tc_data_weight_set(struct aq_hw_s *aq_hw,u32 tx_pkt_shed_tc_data_weight, u32 tc); +/* set tx descriptor rate mode */ +void hw_atl_tps_tx_desc_rate_mode_set (struct aq_hw_s *aq_hw, +const u32 rate_mode); + +/* set tx packet scheduler descriptor rate enable */ +void hw_atl_tps_tx_desc_rate_en_set (struct aq_hw_s *aq_hw,const u32 desc, +const u32 enable); + +/* set tx packet scheduler descriptor rate integral value */ +void hw_atl_tps_tx_desc_rate_x_set (struct aq_hw_s *aq_hw,const u32 desc, +const u32 rate_int); + +/* set tx packet scheduler descriptor rate fractional value */ +void hw_atl_tps_tx_desc_rate_y_set (struct aq_hw_s *aq_hw,const u32 desc, +const u32 rate_frac); +/* tx */ /* set tx register reset disable */
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh_internal.h +70 -0
82 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +5 -4
@@ -135,6 +135,8 @@ static int hw_atl2_hw_qos_set(struct aq_hw_s *self)unsigned int prio =0U ;u32 tc =0U ; +hw_atl_b0_hw_init_tx_tc_rate_limit (self); +/* TPS Descriptor rate init */ hw_atl_tps_tx_pkt_shed_desc_rate_curr_time_res_set (self,0x0U );hw_atl_tps_tx_pkt_shed_desc_rate_lim_set (self,0xA );
@@ -143,7 +145,6 @@ static int hw_atl2_hw_qos_set(struct aq_hw_s *self)hw_atl_tps_tx_pkt_shed_desc_vm_arb_mode_set (self,0U );/* TPS TC credits init */ -hw_atl_tps_tx_pkt_shed_desc_tc_arb_mode_set (self,0U );hw_atl_tps_tx_pkt_shed_data_arb_mode_set (self,0U ); tx_buff_size /= cfg->tcs;
@@ -155,8 +156,6 @@ static int hw_atl2_hw_qos_set(struct aq_hw_s *self)hw_atl2_tps_tx_pkt_shed_tc_data_max_credit_set (self,0xFFF0 , tc);hw_atl2_tps_tx_pkt_shed_tc_data_weight_set (self,0x640 , tc); -hw_atl_tps_tx_pkt_shed_desc_tc_max_credit_set (self,0x50 , tc); -hw_atl_tps_tx_pkt_shed_desc_tc_weight_set (self,0x1E , tc);/* Tx buf size TC0 */ hw_atl_tpb_tx_pkt_buff_size_per_tc_set (self, tx_buff_size, tc);
@@ -215,8 +214,10 @@ static int hw_atl2_hw_rss_set(struct aq_hw_s *self,static int hw_atl2_hw_init_tx_path (struct aq_hw_s *self) { +struct aq_nic_cfg_s *nic_cfg = self->aq_nic_cfg; +/* Tx TC/RSS number config */ -hw_atl_tpb_tps_tx_tc_mode_set (self, self->aq_nic_cfg->tc_mode); +hw_atl_tpb_tps_tx_tc_mode_set (self, nic_cfg->tc_mode);hw_atl_thm_lso_tcp_flag_of_first_pkt_set (self,0x0FF6U );hw_atl_thm_lso_tcp_flag_of_middle_pkt_set (self,0x0FF6U );
Signature · 1 line
2.25.1
Jakub Kicinski
maintainerRe: [PATCH net-next 07/12] net: atlantic: QoS implementation: max_rate
Quoted 4 lines · On Wed, 20 May 2020 16:47:29 +0300 Igor Russkikh wrote:
From: Mark Starovoytov <[email protected]>
This patch adds initial support for mqprio rate limiters (
max_rateonly).
Quoted 8 lines
Atlantic HW supports Rate-Shaping for time-sensitive traffic at per Traffic Class (TC) granularity.
Target rate is defined by:
* nominal link rate (always 10G);
* rate factor (ratio between nominal rate and max allowed).Signed-off-by Mark Starovoytov <[email protected]>Signed-off-by Igor Russkikh <[email protected]>
drivers/net/ethernet/aquantia/atlantic/aq_main.c: In function aq_ndo_setup_tc:drivers/net/ethernet/aquantia/atlantic/aq_main.c:369:7: warning: variable has_max_rate set but not used [-Wunused-but-set-variable]
369 | bool has_max_rate;
| ^~~~~~~~~~~~
drivers/net/ethernet/aquantia/atlantic/aq_main.c:368:7: warning: variable has_min_rate set but not used [-Wunused-but-set-variable]
368 | bool has_min_rate;
| ^~~~~~~~~~~~This probably needs to moved to patch 11 where it's used.
Re: [EXT] Re: [PATCH net-next 07/12] net: atlantic: QoS implementation: max_rate
Quoted 5 lines
drivers/net/ethernet/aquantia/atlantic/aq_main.c: In functionaq_ndo_setup_tc:drivers/net/ethernet/aquantia/atlantic/aq_main.c:369:7: warning: variablehas_max_rateset but not used [-Wunused-but-set-variable]
Quoted 8 lines
369 | bool has_max_rate; | ^~~~~~~~~~~~ drivers/net/ethernet/aquantia/atlantic/aq_main.c:368:7: warning: variable has_min_rate set but not used [-Wunused-but-set-variable] 368 | bool has_min_rate; | ^~~~~~~~~~~~This probably needs to moved to patch 11 where it's used.
Thanks for the review, Jakub, I don't see these on my setup, probably thats newer gcc or different build config.
Will fix this.
Regards,
Igor
PATCH 8/12 net: atlantic: automatically downgrade the number of queues if necessary
In reply to Igor RusskikhFrom: Mark Starovoytov <[email protected]>
This patch adds support for automatic queue number downgrade.
On A2: this is a must have, because only TC0/TC1 support more than 4Q. Other TCs support 4Qs maximum.
Thus, on A2 we must downgrade the number of queues per TC to 4, if more than 2 TCs are requested.
On A1: this allows using 8TCs even on systems with cpu count >= 8, when we have 8 queues by default.
We will just automatically switch to 8TCx4Q mode in this case.
--- .../ethernet/aquantia/atlantic/aq_ethtool.c | 15 +--- .../net/ethernet/aquantia/atlantic/aq_main.c | 5 +- .../net/ethernet/aquantia/atlantic/aq_nic.c | 78 +++++++++++++------ .../net/ethernet/aquantia/atlantic/aq_nic.h | 1 + 4 files changed, 63 insertions(+), 36 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_ethtool.c +4 -11
@@ -793,8 +793,6 @@ static int aq_set_ringparam(struct net_device *ndev,dev_close (ndev); } -aq_nic_free_vectors (aq_nic); - cfg->rxds =max (ring->rx_pending, hw_caps->rxds_min); cfg->rxds =min (cfg->rxds, hw_caps->rxds_max); cfg->rxds =ALIGN (cfg->rxds,AQ_HW_RXD_MULTIPLE );
@@ -803,15 +801,10 @@ static int aq_set_ringparam(struct net_device *ndev, cfg->txds =min (cfg->txds, hw_caps->txds_max); cfg->txds =ALIGN (cfg->txds,AQ_HW_TXD_MULTIPLE ); -for (aq_nic->aq_vecs =0 ; aq_nic->aq_vecs < cfg->vecs; - aq_nic->aq_vecs++) { - aq_nic->aq_vec[aq_nic->aq_vecs] = -aq_vec_alloc (aq_nic, aq_nic->aq_vecs, cfg); -if (unlikely (!aq_nic->aq_vec[aq_nic->aq_vecs])) { - err = -ENOMEM ; - goto err_exit; - } - } + err =aq_nic_realloc_vectors (aq_nic); +if (err) + goto err_exit; +if (ndev_running) err =dev_open (ndev,NULL );
drivers/net/ethernet/aquantia/atlantic/aq_main.c +4 -1
@@ -337,9 +337,12 @@ static int aq_validate_mqprio_opt(struct aq_nic_s *self, const unsigned int num_tc) {const bool has_min_rate = !!(mqprio->flags &TC_MQPRIO_F_MIN_RATE ); +struct aq_nic_cfg_s *aq_nic_cfg =aq_nic_get_cfg (self); +const unsigned int tcs_max =min_t (u8, aq_nic_cfg->aq_hw_caps->tcs_max, +AQ_CFG_TCS_MAX );int i; -if (num_tc >aq_hw_num_tcs (self->aq_hw)) { +if (num_tc > tcs_max) {netdev_err (self->ndev,"Too many TCs requested\n" );return -EOPNOTSUPP ; }
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +54 -24
123 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/aq_nic.h +1 -0
@@ -177,6 +177,7 @@ void aq_nic_deinit(struct aq_nic_s *self, bool link_down);void aq_nic_set_power (struct aq_nic_s *self);void aq_nic_free_hot_resources (struct aq_nic_s *self);void aq_nic_free_vectors (struct aq_nic_s *self); +int aq_nic_realloc_vectors (struct aq_nic_s *self);int aq_nic_set_mtu (struct aq_nic_s *self,int new_mtu);int aq_nic_set_mac (struct aq_nic_s *self,struct net_device *ndev);int aq_nic_set_packet_filter (struct aq_nic_s *self,unsigned int flags);
Signature · 1 line
2.25.1
PATCH 9/12 net: atlantic: always use random TC-queue mapping for TX on A2.
In reply to Igor RusskikhFrom: Mark Starovoytov <[email protected]>
This patch changes the TC-queue mapping mechanism used on A2. Configure the A2 HW in such a way that we can keep queue index mapping exactly as it was on A1.
--- .../aquantia/atlantic/hw_atl2/hw_atl2.c | 31 ++++++++++----- .../aquantia/atlantic/hw_atl2/hw_atl2_llh.c | 9 +++++ .../aquantia/atlantic/hw_atl2/hw_atl2_llh.h | 4 ++ .../atlantic/hw_atl2/hw_atl2_llh_internal.h | 39 ++++++++++++++++++- 4 files changed, 72 insertions(+), 11 deletions(-)
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +22 -9
@@ -95,7 +95,10 @@ static int hw_atl2_hw_queue_to_tc_map_set(struct aq_hw_s *self)struct aq_nic_cfg_s *cfg = self->aq_nic_cfg;unsigned int tcs, q_per_tc;unsigned int tc, q; -u32 value =0 ; +u32 rx_map =0 ; +u32 tx_map =0 ; + +hw_atl2_tpb_tx_tc_q_rand_map_en_set (self,1U );switch (cfg->tc_mode) {case AQ_TC_MODE_8TCS :
@@ -113,14 +116,24 @@ static int hw_atl2_hw_queue_to_tc_map_set(struct aq_hw_s *self)for (tc =0 ; tc != tcs; tc++) {unsigned int tc_q_offset = tc * q_per_tc; -for (q = tc_q_offset; q != tc_q_offset + q_per_tc; q++) - value |= tc <<HW_ATL2_RX_Q_TC_MAP_SHIFT (q); +for (q = tc_q_offset; q != tc_q_offset + q_per_tc; q++) { + rx_map |= tc <<HW_ATL2_RX_Q_TC_MAP_SHIFT (q); +if (HW_ATL2_RX_Q_TC_MAP_ADR (q) != +HW_ATL2_RX_Q_TC_MAP_ADR (q +1 )) { +aq_hw_write_reg (self, +HW_ATL2_RX_Q_TC_MAP_ADR (q), + rx_map); + rx_map =0 ; + } -if (HW_ATL2_RX_Q_TC_MAP_ADR (q) != -HW_ATL2_RX_Q_TC_MAP_ADR (q -1 )) { -aq_hw_write_reg (self,HW_ATL2_RX_Q_TC_MAP_ADR (q -1 ), - value); - value =0 ; + tx_map |= tc <<HW_ATL2_TX_Q_TC_MAP_SHIFT (q); +if (HW_ATL2_TX_Q_TC_MAP_ADR (q) != +HW_ATL2_TX_Q_TC_MAP_ADR (q +1 )) { +aq_hw_write_reg (self, +HW_ATL2_TX_Q_TC_MAP_ADR (q), + tx_map); + tx_map =0 ; + } } }
@@ -181,7 +194,7 @@ static int hw_atl2_hw_qos_set(struct aq_hw_s *self)hw_atl_rpf_rpb_user_priority_tc_map_set (self, prio, cfg->prio_tc_map[prio]); -/* ATL2 Apply legacy ring to TC mapping */ +/* ATL2 Apply ring to TC mapping */ hw_atl2_hw_queue_to_tc_map_set (self);return aq_hw_err_from_flags (self);
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh.c +9 -0
@@ -68,6 +68,15 @@ void hw_atl2_rpf_vlan_flr_tag_set(struct aq_hw_s *aq_hw, u32 tag, u32 filter)/* TX */ +void hw_atl2_tpb_tx_tc_q_rand_map_en_set (struct aq_hw_s *aq_hw, +const u32 tc_q_rand_map_en) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TPB_TX_TC_Q_RAND_MAP_EN_ADR , +HW_ATL2_TPB_TX_TC_Q_RAND_MAP_EN_MSK , +HW_ATL2_TPB_TX_TC_Q_RAND_MAP_EN_SHIFT , + tc_q_rand_map_en); +} +void hw_atl2_tpb_tx_buf_clk_gate_en_set (struct aq_hw_s *aq_hw,u32 clk_gate_en) { aq_hw_write_reg_bit(aq_hw, HW_ATL2_TPB_TX_BUF_CLK_GATE_EN_ADR,
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh.h +4 -0
@@ -38,6 +38,10 @@ void hw_atl2_new_rpf_rss_redir_set(struct aq_hw_s *aq_hw, u32 tc, u32 index,/* Set VLAN filter tag */ void hw_atl2_rpf_vlan_flr_tag_set (struct aq_hw_s *aq_hw,u32 tag,u32 filter); +/* set tx random TC-queue mapping enable bit */ +void hw_atl2_tpb_tx_tc_q_rand_map_en_set (struct aq_hw_s *aq_hw, +const u32 tc_q_rand_map_en); +/* set tx buffer clock gate enable */ void hw_atl2_tpb_tx_buf_clk_gate_en_set (struct aq_hw_s *aq_hw,u32 clk_gate_en);
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh_internal.h +37 -2
@@ -132,6 +132,24 @@/* Default value of bitfield rx_q{Q}_tc_map[2:0] */ #define HW_ATL2_RX_Q_TC_MAP_DEFAULT 0x0 +/* tx tx_tc_q_rand_map_en bitfield definitions +* preprocessor definitions for the bitfield "tx_tc_q_rand_map_en". +* port="pif_tpb_tx_tc_q_rand_map_en_i" +*/ + +/* register address for bitfield tx_tc_q_rand_map_en */ +#define HW_ATL2_TPB_TX_TC_Q_RAND_MAP_EN_ADR 0x00007900 +/* bitmask for bitfield tx_tc_q_rand_map_en */ +#define HW_ATL2_TPB_TX_TC_Q_RAND_MAP_EN_MSK 0x00000200 +/* inverted bitmask for bitfield tx_tc_q_rand_map_en */ +#define HW_ATL2_TPB_TX_TC_Q_RAND_MAP_EN_MSKN 0xFFFFFDFF +/* lower bit position of bitfield tx_tc_q_rand_map_en */ +#define HW_ATL2_TPB_TX_TC_Q_RAND_MAP_EN_SHIFT 9 +/* width of bitfield tx_tc_q_rand_map_en */ +#define HW_ATL2_TPB_TX_TC_Q_RAND_MAP_EN_WIDTH 1 +/* default value of bitfield tx_tc_q_rand_map_en */ +#define HW_ATL2_TPB_TX_TC_Q_RAND_MAP_EN_DEFAULT 0x0 +/* tx tx_buffer_clk_gate_en bitfield definitions * preprocessor definitions for the bitfield "tx_buffer_clk_gate_en". * port="pif_tpb_tx_buffer_clk_gate_en_i"
@@ -150,8 +168,25 @@/* default value of bitfield tx_buffer_clk_gate_en */ #define HW_ATL2_TPB_TX_BUF_CLK_GATE_EN_DEFAULT 0x0 -/* tx data_tc{t}_credit_max[b:0] bitfield definitions -* preprocessor definitions for the bitfield "data_tc{t}_credit_max[b:0]". +/* tx tx_q_tc_map{q} bitfield definitions +* preprocessor definitions for the bitfield "tx_q_tc_map{q}". +* parameter: queue {q} | bit-level stride | range [0, 31] +* port="pif_tpb_tx_q_tc_map0_i[2:0]" +*/ + +/* register address for bitfield tx_q_tc_map{q} */ +#define HW_ATL2_TX_Q_TC_MAP_ADR (queue) \ + (((queue) < 32) ? 0x0000799C + ((queue) / 4) * 4 : 0) +/* lower bit position of bitfield tx_q_tc_map{q} */ +#define HW_ATL2_TX_Q_TC_MAP_SHIFT (queue) \ + (((queue) < 32) ? ((queue) * 8) % 32 : 0) +/* width of bitfield tx_q_tc_map{q} */ +#define HW_ATL2_TX_Q_TC_MAP_WIDTH 3 +/* default value of bitfield tx_q_tc_map{q} */ +#define HW_ATL2_TX_Q_TC_MAP_DEFAULT 0x0 + +/* tx data_tc{t}_credit_max[f:0] bitfield definitions +* preprocessor definitions for the bitfield "data_tc{t}_credit_max[f:0]". * parameter: tc {t} | stride size 0x4 | range [0, 7] * port="pif_tps_data_tc0_credit_max_i[11:0]" */
Signature · 1 line
2.25.1
PATCH 10/12 net: atlantic: change the order of arguments for TC weight/credit setters
In reply to Igor RusskikhFrom: Mark Starovoytov <[email protected]>
This patch changes the order of arguments for TC weight/credit setter functions.
Having the "value to be set" on the right is slightly more robust in a sense that it's more natural for the humans, so it's a bit more error-proof this way.
--- .../aquantia/atlantic/hw_atl/hw_atl_a0.c | 8 ++++---- .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 8 ++++---- .../aquantia/atlantic/hw_atl/hw_atl_llh.c | 20 +++++++++---------- .../aquantia/atlantic/hw_atl/hw_atl_llh.h | 16 +++++++-------- .../aquantia/atlantic/hw_atl2/hw_atl2_llh.c | 10 +++++----- .../aquantia/atlantic/hw_atl2/hw_atl2_llh.h | 8 ++++---- 6 files changed, 35 insertions(+), 35 deletions(-)
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_a0.c +4 -4
@@ -136,10 +136,10 @@ static int hw_atl_a0_hw_qos_set(struct aq_hw_s *self)hw_atl_tps_tx_pkt_shed_desc_tc_arb_mode_set (self,0U );hw_atl_tps_tx_pkt_shed_data_arb_mode_set (self,0U ); -hw_atl_tps_tx_pkt_shed_tc_data_max_credit_set (self,0xFFF ,0U ); -hw_atl_tps_tx_pkt_shed_tc_data_weight_set (self,0x64 ,0U ); -hw_atl_tps_tx_pkt_shed_desc_tc_max_credit_set (self,0x50 ,0U ); -hw_atl_tps_tx_pkt_shed_desc_tc_weight_set (self,0x1E ,0U ); +hw_atl_tps_tx_pkt_shed_tc_data_max_credit_set (self,0U ,0xFFF ); +hw_atl_tps_tx_pkt_shed_tc_data_weight_set (self,0U ,0x64 ); +hw_atl_tps_tx_pkt_shed_desc_tc_max_credit_set (self,0U ,0x50 ); +hw_atl_tps_tx_pkt_shed_desc_tc_weight_set (self,0U ,0x1E );/* Tx buf size */ buff_size =HW_ATL_A0_TXBUF_MAX ;
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +4 -4
@@ -161,8 +161,8 @@ static int hw_atl_b0_hw_qos_set(struct aq_hw_s *self)u32 threshold =0U ;/* TX Packet Scheduler Data TC0 */ -hw_atl_tps_tx_pkt_shed_tc_data_max_credit_set (self,0xFFF , tc); -hw_atl_tps_tx_pkt_shed_tc_data_weight_set (self,0x64 , tc); +hw_atl_tps_tx_pkt_shed_tc_data_max_credit_set (self, tc,0xFFF ); +hw_atl_tps_tx_pkt_shed_tc_data_weight_set (self, tc,0x64 );/* Tx buf size TC0 */ hw_atl_tpb_tx_pkt_buff_size_per_tc_set (self, tx_buff_size, tc);
@@ -334,8 +334,8 @@ int hw_atl_b0_hw_init_tx_tc_rate_limit(struct aq_hw_s *self)const u32 en = (nic_cfg->tc_max_rate[tc] !=0 ) ?1U :0U ;const u32 desc =AQ_NIC_CFG_TCVEC2RING (nic_cfg, tc,0 ); -hw_atl_tps_tx_pkt_shed_desc_tc_max_credit_set (self,0x50 , tc); -hw_atl_tps_tx_pkt_shed_desc_tc_weight_set (self,0x1E , tc); +hw_atl_tps_tx_pkt_shed_desc_tc_max_credit_set (self, tc,0x50 ); +hw_atl_tps_tx_pkt_shed_desc_tc_weight_set (self, tc,0x1E );hw_atl_tps_tx_desc_rate_en_set (self, desc, en);
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.c +10 -10
@@ -1463,8 +1463,8 @@ void hw_atl_tps_tx_pkt_shed_desc_tc_arb_mode_set(struct aq_hw_s *aq_hw, }void hw_atl_tps_tx_pkt_shed_desc_tc_max_credit_set (struct aq_hw_s *aq_hw, -u32 max_credit, -u32 tc) +const u32 tc, +const u32 max_credit) { aq_hw_write_reg_bit(aq_hw, HW_ATL_TPS_DESC_TCTCREDIT_MAX_ADR(tc), HW_ATL_TPS_DESC_TCTCREDIT_MAX_MSK,
@@ -1473,13 +1473,13 @@ void hw_atl_tps_tx_pkt_shed_desc_tc_max_credit_set(struct aq_hw_s *aq_hw, }void hw_atl_tps_tx_pkt_shed_desc_tc_weight_set (struct aq_hw_s *aq_hw, -u32 tx_pkt_shed_desc_tc_weight, -u32 tc) +const u32 tc, +const u32 weight) {aq_hw_write_reg_bit (aq_hw,HW_ATL_TPS_DESC_TCTWEIGHT_ADR (tc),HW_ATL_TPS_DESC_TCTWEIGHT_MSK ,HW_ATL_TPS_DESC_TCTWEIGHT_SHIFT , - tx_pkt_shed_desc_tc_weight); + weight); } void hw_atl_tps_tx_pkt_shed_desc_vm_arb_mode_set(struct aq_hw_s *aq_hw,
@@ -1492,8 +1492,8 @@ void hw_atl_tps_tx_pkt_shed_desc_vm_arb_mode_set(struct aq_hw_s *aq_hw, }void hw_atl_tps_tx_pkt_shed_tc_data_max_credit_set (struct aq_hw_s *aq_hw, -u32 max_credit, -u32 tc) +const u32 tc, +const u32 max_credit) { aq_hw_write_reg_bit(aq_hw, HW_ATL_TPS_DATA_TCTCREDIT_MAX_ADR(tc), HW_ATL_TPS_DATA_TCTCREDIT_MAX_MSK,
@@ -1502,13 +1502,13 @@ void hw_atl_tps_tx_pkt_shed_tc_data_max_credit_set(struct aq_hw_s *aq_hw, }void hw_atl_tps_tx_pkt_shed_tc_data_weight_set (struct aq_hw_s *aq_hw, -u32 tx_pkt_shed_tc_data_weight, -u32 tc) +const u32 tc, +const u32 weight) {aq_hw_write_reg_bit (aq_hw,HW_ATL_TPS_DATA_TCTWEIGHT_ADR (tc),HW_ATL_TPS_DATA_TCTWEIGHT_MSK ,HW_ATL_TPS_DATA_TCTWEIGHT_SHIFT , - tx_pkt_shed_tc_data_weight); + weight); } void hw_atl_tps_tx_desc_rate_mode_set(struct aq_hw_s *aq_hw,
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_llh.h +8 -8
@@ -688,13 +688,13 @@ void hw_atl_tps_tx_pkt_shed_desc_tc_arb_mode_set(struct aq_hw_s *aq_hw,/* set tx packet scheduler descriptor tc max credit */ void hw_atl_tps_tx_pkt_shed_desc_tc_max_credit_set (struct aq_hw_s *aq_hw, -u32 max_credit, -u32 tc); +const u32 tc, +const u32 max_credit);/* set tx packet scheduler descriptor tc weight */ void hw_atl_tps_tx_pkt_shed_desc_tc_weight_set (struct aq_hw_s *aq_hw, -u32 tx_pkt_shed_desc_tc_weight, -u32 tc); +const u32 tc, +const u32 weight);/* set tx packet scheduler descriptor vm arbitration mode */ void hw_atl_tps_tx_pkt_shed_desc_vm_arb_mode_set(struct aq_hw_s *aq_hw,
@@ -702,13 +702,13 @@ void hw_atl_tps_tx_pkt_shed_desc_vm_arb_mode_set(struct aq_hw_s *aq_hw,/* set tx packet scheduler tc data max credit */ void hw_atl_tps_tx_pkt_shed_tc_data_max_credit_set (struct aq_hw_s *aq_hw, -u32 max_credit, -u32 tc); +const u32 tc, +const u32 max_credit);/* set tx packet scheduler tc data weight */ void hw_atl_tps_tx_pkt_shed_tc_data_weight_set (struct aq_hw_s *aq_hw, -u32 tx_pkt_shed_tc_data_weight, -u32 tc); +const u32 tc, +const u32 weight);/* set tx descriptor rate mode */ void hw_atl_tps_tx_desc_rate_mode_set(struct aq_hw_s *aq_hw,
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh.c +5 -5
@@ -94,8 +94,8 @@ void hw_atl2_reg_tx_intr_moder_ctrl_set(struct aq_hw_s *aq_hw, }void hw_atl2_tps_tx_pkt_shed_tc_data_max_credit_set (struct aq_hw_s *aq_hw, -u32 max_credit, -u32 tc) +const u32 tc, +const u32 max_credit) { aq_hw_write_reg_bit(aq_hw, HW_ATL2_TPS_DATA_TCTCREDIT_MAX_ADR(tc), HW_ATL2_TPS_DATA_TCTCREDIT_MAX_MSK,
@@ -104,13 +104,13 @@ void hw_atl2_tps_tx_pkt_shed_tc_data_max_credit_set(struct aq_hw_s *aq_hw, }void hw_atl2_tps_tx_pkt_shed_tc_data_weight_set (struct aq_hw_s *aq_hw, -u32 tx_pkt_shed_tc_data_weight, -u32 tc) +const u32 tc, +const u32 weight) {aq_hw_write_reg_bit (aq_hw,HW_ATL2_TPS_DATA_TCTWEIGHT_ADR (tc),HW_ATL2_TPS_DATA_TCTWEIGHT_MSK ,HW_ATL2_TPS_DATA_TCTWEIGHT_SHIFT , - tx_pkt_shed_tc_data_weight); + weight); }u32 hw_atl2_get_hw_version (struct aq_hw_s *aq_hw)
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh.h +4 -4
@@ -47,13 +47,13 @@ void hw_atl2_tpb_tx_buf_clk_gate_en_set(struct aq_hw_s *aq_hw, u32 clk_gate_en);/* set tx packet scheduler tc data max credit */ void hw_atl2_tps_tx_pkt_shed_tc_data_max_credit_set (struct aq_hw_s *aq_hw, -u32 max_credit, -u32 tc); +const u32 tc, +const u32 max_credit);/* set tx packet scheduler tc data weight */ void hw_atl2_tps_tx_pkt_shed_tc_data_weight_set (struct aq_hw_s *aq_hw, -u32 tx_pkt_shed_tc_data_weight, -u32 tc); +const u32 tc, +const u32 weight);u32 hw_atl2_get_hw_version (struct aq_hw_s *aq_hw);
Signature · 1 line
2.25.1
PATCH 11/12 net: atlantic: QoS implementation: min_rate
In reply to Igor RusskikhFrom: Mark Starovoytov <[email protected]>
This patch adds support for mqprio min_rate limiters.
A2 HW supports Weighted Strict Priority (WSP) arbitration for Tx Descriptor Queue scheduling among TCs, which can be used for min_rate shaping.
--- .../net/ethernet/aquantia/atlantic/aq_hw.h | 2 + .../net/ethernet/aquantia/atlantic/aq_main.c | 21 +-- .../net/ethernet/aquantia/atlantic/aq_nic.c | 28 ++++ .../net/ethernet/aquantia/atlantic/aq_nic.h | 4 + .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 77 +++++++++-- .../aquantia/atlantic/hw_atl/hw_atl_b0.h | 2 - .../aquantia/atlantic/hw_atl2/hw_atl2.c | 127 ++++++++++++++++-- .../aquantia/atlantic/hw_atl2/hw_atl2_llh.c | 9 ++ .../aquantia/atlantic/hw_atl2/hw_atl2_llh.h | 3 + .../atlantic/hw_atl2/hw_atl2_llh_internal.h | 62 ++++++--- 10 files changed, 281 insertions(+), 54 deletions(-)
drivers/net/ethernet/aquantia/atlantic/aq_hw.h +2 -0
@@ -280,6 +280,8 @@ struct aq_hw_ops {int (*hw_rss_hash_set)(struct aq_hw_s *self,struct aq_rss_parameters *rss_params); +int (*hw_tc_rate_limit_set)(struct aq_hw_s *self); +int (*hw_get_regs)(struct aq_hw_s *self,const struct aq_hw_caps_s *aq_hw_caps,u32 *regs_buff);
drivers/net/ethernet/aquantia/atlantic/aq_main.c +12 -9
@@ -340,7 +340,6 @@ static int aq_validate_mqprio_opt(struct aq_nic_s *self,struct aq_nic_cfg_s *aq_nic_cfg =aq_nic_get_cfg (self);const unsigned int tcs_max =min_t (u8, aq_nic_cfg->aq_hw_caps->tcs_max,AQ_CFG_TCS_MAX ); -int i;if (num_tc > tcs_max) {netdev_err (self->ndev,"Too many TCs requested\n" );
@@ -352,12 +351,9 @@ static int aq_validate_mqprio_opt(struct aq_nic_s *self,return -EOPNOTSUPP ; } -for (i =0 ; i < num_tc; i++) { -if (has_min_rate && mqprio->min_rate[i]) { -netdev_err (self->ndev, -"Min tx rate is not supported\n" ); -return -EOPNOTSUPP ; - } +if (has_min_rate && !ATL_HW_IS_CHIP_FEATURE (self->aq_hw,ANTIGUA )) { +netdev_err (self->ndev,"Min tx rate is not supported\n" ); +return -EOPNOTSUPP ; }return 0 ;
@@ -383,13 +379,20 @@ static int aq_ndo_setup_tc(struct net_device *dev, enum tc_setup_type type,if (err)return err; -if (mqprio->flags &TC_MQPRIO_F_MAX_RATE ) { -for (i =0 ; i < mqprio->qopt.num_tc; i++) { +for (i =0 ; i < mqprio->qopt.num_tc; i++) { +if (has_max_rate) {u64 max_rate = mqprio->max_rate[i];do_div (max_rate,AQ_MBPS_DIVISOR );aq_nic_setup_tc_max_rate (aq_nic, i, (u32 )max_rate); } + +if (has_min_rate) { +u64 min_rate = mqprio->min_rate[i]; + +do_div (min_rate,AQ_MBPS_DIVISOR ); +aq_nic_setup_tc_min_rate (aq_nic, i, (u32 )min_rate); + } } return aq_nic_setup_tc_mqprio(aq_nic, mqprio->qopt.num_tc,
drivers/net/ethernet/aquantia/atlantic/aq_nic.c +28 -0
@@ -200,6 +200,9 @@ static int aq_nic_update_link_status(struct aq_nic_s *self)#if IS_ENABLED (CONFIG_MACSEC )aq_macsec_enable (self);#endif +if (self->aq_hw_ops->hw_tc_rate_limit_set) + self->aq_hw_ops->hw_tc_rate_limit_set (self->aq_hw); +netif_tx_wake_all_queues (self->ndev); }if (netif_carrier_ok (self->ndev) && !self->link_status.mbps) {
@@ -1375,3 +1378,28 @@ int aq_nic_setup_tc_max_rate(struct aq_nic_s *self, const unsigned int tc,return 0 ; } + +int aq_nic_setup_tc_min_rate (struct aq_nic_s *self,const unsigned int tc, +const u32 min_rate) +{ +struct aq_nic_cfg_s *cfg = &self->aq_nic_cfg; + +if (tc >=AQ_CFG_TCS_MAX ) +return -EINVAL ; + +if (min_rate) +set_bit (tc, &cfg->tc_min_rate_msk); +else +clear_bit (tc, &cfg->tc_min_rate_msk); + +if (min_rate && min_rate <20 ) { +netdev_warn (self->ndev, +"Setting %s to the minimum usable value of %dMbps.\n" , +"min rate" ,20 ); + cfg->tc_min_rate[tc] =20 ; + }else { + cfg->tc_min_rate[tc] = min_rate; + } + +return 0 ; +}
drivers/net/ethernet/aquantia/atlantic/aq_nic.h +4 -0
@@ -66,6 +66,8 @@ struct aq_nic_cfg_s {u8 tcs;u8 prio_tc_map[8 ];u32 tc_max_rate[AQ_CFG_TCS_MAX ]; +unsigned long tc_min_rate_msk; +u32 tc_min_rate[AQ_CFG_TCS_MAX ];struct aq_rss_parameters aq_rss;u32 eee_speeds; };
@@ -198,4 +200,6 @@ void aq_nic_release_filter(struct aq_nic_s *self, enum aq_rx_filter_type type,int aq_nic_setup_tc_mqprio (struct aq_nic_s *self,u32 tcs,u8 *prio_tc_map);int aq_nic_setup_tc_max_rate (struct aq_nic_s *self,const unsigned int tc,const u32 max_rate); +int aq_nic_setup_tc_min_rate (struct aq_nic_s *self,const unsigned int tc, +const u32 min_rate);#endif /* AQ_NIC_H */
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +66 -11
122 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.h +0 -2
@@ -62,8 +62,6 @@ int hw_atl_b0_hw_mac_addr_set(struct aq_hw_s *self, u8 *mac_addr);int hw_atl_b0_hw_start (struct aq_hw_s *self); -int hw_atl_b0_hw_init_tx_tc_rate_limit (struct aq_hw_s *self); -int hw_atl_b0_hw_irq_enable (struct aq_hw_s *self,u64 mask);int hw_atl_b0_hw_irq_disable (struct aq_hw_s *self,u64 mask);int hw_atl_b0_hw_irq_read (struct aq_hw_s *self,u64 *mask);
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +117 -10
162 lines not on this page · raw message
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh.c +9 -0
@@ -93,6 +93,15 @@ void hw_atl2_reg_tx_intr_moder_ctrl_set(struct aq_hw_s *aq_hw, tx_intr_moderation_ctl); } +void hw_atl2_tps_tx_pkt_shed_data_arb_mode_set (struct aq_hw_s *aq_hw, +const u32 data_arb_mode) +{ +aq_hw_write_reg_bit (aq_hw,HW_ATL2_TPS_DATA_TC_ARB_MODE_ADR , +HW_ATL2_TPS_DATA_TC_ARB_MODE_MSK , +HW_ATL2_TPS_DATA_TC_ARB_MODE_SHIFT , + data_arb_mode); +} +void hw_atl2_tps_tx_pkt_shed_tc_data_max_credit_set (struct aq_hw_s *aq_hw,const u32 tc,const u32 max_credit)
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh.h +3 -0
@@ -45,6 +45,9 @@ void hw_atl2_tpb_tx_tc_q_rand_map_en_set(struct aq_hw_s *aq_hw,/* set tx buffer clock gate enable */ void hw_atl2_tpb_tx_buf_clk_gate_en_set (struct aq_hw_s *aq_hw,u32 clk_gate_en); +void hw_atl2_tps_tx_pkt_shed_data_arb_mode_set (struct aq_hw_s *aq_hw, +const u32 data_arb_mode); +/* set tx packet scheduler tc data max credit */ void hw_atl2_tps_tx_pkt_shed_tc_data_max_credit_set(struct aq_hw_s *aq_hw, const u32 tc,
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_llh_internal.h +40 -22
82 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 12/12 net: atlantic: proper rss_ctrl1 (54c0) initialization
In reply to Igor RusskikhFrom: Mark Starovoytov <[email protected]>
This patch fixes an inconsistency between code and spec, which was found while working on the QoS implementation.
When 8TCs are used, 2 is the maximum supported number of index bits. In a 4TC mode, we do support 3, but we shouldn't really use the bytes, which are intended for the 8TC mode.
--- .../aquantia/atlantic/hw_atl/hw_atl_b0.c | 16 ++++++++++++++-- .../aquantia/atlantic/hw_atl/hw_atl_b0.h | 2 ++ .../atlantic/hw_atl/hw_atl_b0_internal.h | 4 ++++ .../ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c | 4 +--- .../aquantia/atlantic/hw_atl2/hw_atl2_internal.h | 3 --- 5 files changed, 21 insertions(+), 8 deletions(-)
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +14 -2
@@ -447,6 +447,19 @@ static int hw_atl_b0_hw_init_tx_path(struct aq_hw_s *self)return aq_hw_err_from_flags (self); } +void hw_atl_b0_hw_init_rx_rss_ctrl1 (struct aq_hw_s *self) +{ +struct aq_nic_cfg_s *cfg = self->aq_nic_cfg; +u32 rss_ctrl1 =HW_ATL_RSS_DISABLED ; + +if (cfg->is_rss) + rss_ctrl1 = (cfg->tc_mode ==AQ_TC_MODE_8TCS ) ? +HW_ATL_RSS_ENABLED_8TCS_2INDEX_BITS : +HW_ATL_RSS_ENABLED_4TCS_3INDEX_BITS ; + +hw_atl_reg_rx_flr_rss_control1set (self, rss_ctrl1); +} +static int hw_atl_b0_hw_init_rx_path (struct aq_hw_s *self) {struct aq_nic_cfg_s *cfg = self->aq_nic_cfg;
@@ -459,8 +472,7 @@ static int hw_atl_b0_hw_init_rx_path(struct aq_hw_s *self)hw_atl_rpb_rx_flow_ctl_mode_set (self,1U );/* RSS Ring selection */ -hw_atl_reg_rx_flr_rss_control1set (self, cfg->is_rss ? -0xB3333333U :0x00000000U ); +hw_atl_b0_hw_init_rx_rss_ctrl1 (self);/* Multicast filters */ for (i =HW_ATL_B0_MAC_MAX ; i--;) {
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.h +2 -0
@@ -58,6 +58,8 @@ int hw_atl_b0_hw_ring_tx_head_update(struct aq_hw_s *self,int hw_atl_b0_hw_ring_tx_stop (struct aq_hw_s *self,struct aq_ring_s *ring);int hw_atl_b0_hw_ring_rx_stop (struct aq_hw_s *self,struct aq_ring_s *ring); +void hw_atl_b0_hw_init_rx_rss_ctrl1 (struct aq_hw_s *self); +int hw_atl_b0_hw_mac_addr_set (struct aq_hw_s *self,u8 *mac_addr);int hw_atl_b0_hw_start (struct aq_hw_s *self);
drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0_internal.h +4 -0
@@ -151,6 +151,10 @@#define HW_ATL_B0_MAX_RXD 8184U#define HW_ATL_B0_MAX_TXD 8184U +#define HW_ATL_RSS_DISABLED 0x00000000U +#define HW_ATL_RSS_ENABLED_8TCS_2INDEX_BITS 0xA2222222U +#define HW_ATL_RSS_ENABLED_4TCS_3INDEX_BITS 0x80003333U +/* HW layer capabilities */ #endif /* HW_ATL_B0_INTERNAL_H */
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2.c +1 -3
@@ -475,9 +475,7 @@ static int hw_atl2_hw_init_rx_path(struct aq_hw_s *self)hw_atl2_rpf_rss_hash_type_set (self,HW_ATL2_RPF_RSS_HASH_TYPE_ALL );/* RSS Ring selection */ -hw_atl_reg_rx_flr_rss_control1set (self, cfg->is_rss ? -HW_ATL_RSS_ENABLED_3INDEX_BITS : -HW_ATL_RSS_DISABLED ); +hw_atl_b0_hw_init_rx_rss_ctrl1 (self);/* Multicast filters */ for (i =HW_ATL2_MAC_MAX ; i--;) {
drivers/net/ethernet/aquantia/atlantic/hw_atl2/hw_atl2_internal.h +0 -3
@@ -117,9 +117,6 @@ enum HW_ATL2_RPF_RSS_HASH_TYPE { HW_ATL2_RPF_RSS_HASH_TYPE_IPV6_EX_UDP, }; -#define HW_ATL_RSS_DISABLED 0x00000000U -#define HW_ATL_RSS_ENABLED_3INDEX_BITS 0xB3333333U -#define HW_ATL_MCAST_FLT_ANY_TO_HOST 0x00010FFFUstruct hw_atl2_priv {
Signature · 1 line
2.25.1