@@ -1387,6 +1387,9 @@ static void otx2_free_sq_res(struct otx2_nic *pf)
13871387 otx2_sq_free_sqbs (pf );
13881388 for (qidx = 0 ; qidx < otx2_get_total_tx_queues (pf ); qidx ++ ) {
13891389 sq = & qset -> sq [qidx ];
1390+ /* Skip freeing Qos queues if they are not initialized */
1391+ if (!sq -> sqe )
1392+ continue ;
13901393 qmem_free (pf -> dev , sq -> sqe );
13911394 qmem_free (pf -> dev , sq -> tso_hdrs );
13921395 kfree (sq -> sg );
@@ -1566,6 +1569,8 @@ static void otx2_free_hw_resources(struct otx2_nic *pf)
15661569 otx2_pfc_txschq_stop (pf );
15671570#endif
15681571
1572+ otx2_clean_qos_queues (pf );
1573+
15691574 mutex_lock (& mbox -> lock );
15701575 /* Disable backpressure */
15711576 if (!(pf -> pcifunc & RVU_PFVF_FUNC_MASK ))
@@ -1710,7 +1715,7 @@ int otx2_open(struct net_device *netdev)
17101715 if (!qset -> cq )
17111716 goto err_free_mem ;
17121717
1713- qset -> sq = kcalloc (pf -> hw . non_qos_queues ,
1718+ qset -> sq = kcalloc (otx2_get_total_tx_queues ( pf ) ,
17141719 sizeof (struct otx2_snd_queue ), GFP_KERNEL );
17151720 if (!qset -> sq )
17161721 goto err_free_mem ;
@@ -1833,6 +1838,9 @@ int otx2_open(struct net_device *netdev)
18331838 /* 'intf_down' may be checked on any cpu */
18341839 smp_wmb ();
18351840
1841+ /* Enable QoS configuration before starting tx queues */
1842+ otx2_qos_config_txschq (pf );
1843+
18361844 /* we have already received link status notification */
18371845 if (pf -> linfo .link_up && !(pf -> pcifunc & RVU_PFVF_FUNC_MASK ))
18381846 otx2_handle_link_event (pf );
@@ -1986,14 +1994,48 @@ static netdev_tx_t otx2_xmit(struct sk_buff *skb, struct net_device *netdev)
19861994 return NETDEV_TX_OK ;
19871995}
19881996
1997+ static int otx2_qos_select_htb_queue (struct otx2_nic * pf , struct sk_buff * skb ,
1998+ u16 htb_maj_id )
1999+ {
2000+ u16 classid ;
2001+
2002+ if ((TC_H_MAJ (skb -> priority ) >> 16 ) == htb_maj_id )
2003+ classid = TC_H_MIN (skb -> priority );
2004+ else
2005+ classid = READ_ONCE (pf -> qos .defcls );
2006+
2007+ if (!classid )
2008+ return 0 ;
2009+
2010+ return otx2_get_txq_by_classid (pf , classid );
2011+ }
2012+
19892013u16 otx2_select_queue (struct net_device * netdev , struct sk_buff * skb ,
19902014 struct net_device * sb_dev )
19912015{
1992- #ifdef CONFIG_DCB
19932016 struct otx2_nic * pf = netdev_priv (netdev );
2017+ bool qos_enabled ;
2018+ #ifdef CONFIG_DCB
19942019 u8 vlan_prio ;
19952020#endif
2021+ int txq ;
2022+
2023+ qos_enabled = (netdev -> real_num_tx_queues > pf -> hw .tx_queues ) ? true : false;
2024+ if (unlikely (qos_enabled )) {
2025+ /* This smp_load_acquire() pairs with smp_store_release() in
2026+ * otx2_qos_root_add() called from htb offload root creation
2027+ */
2028+ u16 htb_maj_id = smp_load_acquire (& pf -> qos .maj_id );
19962029
2030+ if (unlikely (htb_maj_id )) {
2031+ txq = otx2_qos_select_htb_queue (pf , skb , htb_maj_id );
2032+ if (txq > 0 )
2033+ return txq ;
2034+ goto process_pfc ;
2035+ }
2036+ }
2037+
2038+ process_pfc :
19972039#ifdef CONFIG_DCB
19982040 if (!skb_vlan_tag_present (skb ))
19992041 goto pick_tx ;
@@ -2007,7 +2049,11 @@ u16 otx2_select_queue(struct net_device *netdev, struct sk_buff *skb,
20072049
20082050pick_tx :
20092051#endif
2010- return netdev_pick_tx (netdev , skb , NULL );
2052+ txq = netdev_pick_tx (netdev , skb , NULL );
2053+ if (unlikely (qos_enabled ))
2054+ return txq % pf -> hw .tx_queues ;
2055+
2056+ return txq ;
20112057}
20122058EXPORT_SYMBOL (otx2_select_queue );
20132059
@@ -3121,6 +3167,7 @@ static void otx2_remove(struct pci_dev *pdev)
31213167 otx2_ptp_destroy (pf );
31223168 otx2_mcam_flow_del (pf );
31233169 otx2_shutdown_tc (pf );
3170+ otx2_shutdown_qos (pf );
31243171 otx2_detach_resources (& pf -> mbox );
31253172 if (pf -> hw .lmt_info )
31263173 free_percpu (pf -> hw .lmt_info );
0 commit comments