@@ -581,7 +581,7 @@ static int otx2_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *nfc)
581581 break ;
582582 case ETHTOOL_SRXCLSRLINS :
583583 if (netif_running (dev ) && ntuple )
584- ret = otx2_add_flow (pfvf , & nfc -> fs );
584+ ret = otx2_add_flow (pfvf , nfc );
585585 break ;
586586 case ETHTOOL_SRXCLSRLDEL :
587587 if (netif_running (dev ) && ntuple )
@@ -641,42 +641,50 @@ static u32 otx2_get_rxfh_key_size(struct net_device *netdev)
641641
642642static u32 otx2_get_rxfh_indir_size (struct net_device * dev )
643643{
644- struct otx2_nic * pfvf = netdev_priv (dev );
645-
646- return pfvf -> hw .rss_info .rss_size ;
644+ return MAX_RSS_INDIR_TBL_SIZE ;
647645}
648646
649- /* Get RSS configuration */
650- static int otx2_get_rxfh (struct net_device * dev , u32 * indir ,
651- u8 * hkey , u8 * hfunc )
647+ static int otx2_rss_ctx_delete (struct otx2_nic * pfvf , int ctx_id )
652648{
653- struct otx2_nic * pfvf = netdev_priv (dev );
654- struct otx2_rss_info * rss ;
655- int idx ;
649+ struct otx2_rss_info * rss = & pfvf -> hw .rss_info ;
656650
657- rss = & pfvf -> hw .rss_info ;
651+ otx2_rss_ctx_flow_del (pfvf , ctx_id );
652+ kfree (rss -> rss_ctx [ctx_id ]);
653+ rss -> rss_ctx [ctx_id ] = NULL ;
658654
659- if (indir ) {
660- for (idx = 0 ; idx < rss -> rss_size ; idx ++ )
661- indir [idx ] = rss -> ind_tbl [idx ];
662- }
655+ return 0 ;
656+ }
663657
664- if (hkey )
665- memcpy (hkey , rss -> key , sizeof (rss -> key ));
658+ static int otx2_rss_ctx_create (struct otx2_nic * pfvf ,
659+ u32 * rss_context )
660+ {
661+ struct otx2_rss_info * rss = & pfvf -> hw .rss_info ;
662+ u8 ctx ;
666663
667- if (hfunc )
668- * hfunc = ETH_RSS_HASH_TOP ;
664+ for (ctx = 0 ; ctx < MAX_RSS_GROUPS ; ctx ++ ) {
665+ if (!rss -> rss_ctx [ctx ])
666+ break ;
667+ }
668+ if (ctx == MAX_RSS_GROUPS )
669+ return - EINVAL ;
670+
671+ rss -> rss_ctx [ctx ] = kzalloc (sizeof (* rss -> rss_ctx [ctx ]), GFP_KERNEL );
672+ if (!rss -> rss_ctx [ctx ])
673+ return - ENOMEM ;
674+ * rss_context = ctx ;
669675
670676 return 0 ;
671677}
672678
673- /* Configure RSS table and hash key */
674- static int otx2_set_rxfh (struct net_device * dev , const u32 * indir ,
675- const u8 * hkey , const u8 hfunc )
679+ /* RSS context configuration */
680+ static int otx2_set_rxfh_context (struct net_device * dev , const u32 * indir ,
681+ const u8 * hkey , const u8 hfunc ,
682+ u32 * rss_context , bool delete )
676683{
677684 struct otx2_nic * pfvf = netdev_priv (dev );
685+ struct otx2_rss_ctx * rss_ctx ;
678686 struct otx2_rss_info * rss ;
679- int idx ;
687+ int ret , idx ;
680688
681689 if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP )
682690 return - EOPNOTSUPP ;
@@ -688,20 +696,85 @@ static int otx2_set_rxfh(struct net_device *dev, const u32 *indir,
688696 return - EIO ;
689697 }
690698
699+ if (hkey ) {
700+ memcpy (rss -> key , hkey , sizeof (rss -> key ));
701+ otx2_set_rss_key (pfvf );
702+ }
703+ if (delete )
704+ return otx2_rss_ctx_delete (pfvf , * rss_context );
705+
706+ if (* rss_context == ETH_RXFH_CONTEXT_ALLOC ) {
707+ ret = otx2_rss_ctx_create (pfvf , rss_context );
708+ if (ret )
709+ return ret ;
710+ }
691711 if (indir ) {
712+ rss_ctx = rss -> rss_ctx [* rss_context ];
692713 for (idx = 0 ; idx < rss -> rss_size ; idx ++ )
693- rss -> ind_tbl [idx ] = indir [idx ];
714+ rss_ctx -> ind_tbl [idx ] = indir [idx ];
694715 }
716+ otx2_set_rss_table (pfvf , * rss_context );
695717
696- if (hkey ) {
697- memcpy (rss -> key , hkey , sizeof (rss -> key ));
698- otx2_set_rss_key (pfvf );
718+ return 0 ;
719+ }
720+
721+ static int otx2_get_rxfh_context (struct net_device * dev , u32 * indir ,
722+ u8 * hkey , u8 * hfunc , u32 rss_context )
723+ {
724+ struct otx2_nic * pfvf = netdev_priv (dev );
725+ struct otx2_rss_ctx * rss_ctx ;
726+ struct otx2_rss_info * rss ;
727+ int idx , rx_queues ;
728+
729+ rss = & pfvf -> hw .rss_info ;
730+
731+ if (hfunc )
732+ * hfunc = ETH_RSS_HASH_TOP ;
733+
734+ if (!indir )
735+ return 0 ;
736+
737+ if (!rss -> enable && rss_context == DEFAULT_RSS_CONTEXT_GROUP ) {
738+ rx_queues = pfvf -> hw .rx_queues ;
739+ for (idx = 0 ; idx < MAX_RSS_INDIR_TBL_SIZE ; idx ++ )
740+ indir [idx ] = ethtool_rxfh_indir_default (idx , rx_queues );
741+ return 0 ;
742+ }
743+ if (rss_context >= MAX_RSS_GROUPS )
744+ return - ENOENT ;
745+
746+ rss_ctx = rss -> rss_ctx [rss_context ];
747+ if (!rss_ctx )
748+ return - ENOENT ;
749+
750+ if (indir ) {
751+ for (idx = 0 ; idx < rss -> rss_size ; idx ++ )
752+ indir [idx ] = rss_ctx -> ind_tbl [idx ];
699753 }
754+ if (hkey )
755+ memcpy (hkey , rss -> key , sizeof (rss -> key ));
700756
701- otx2_set_rss_table (pfvf );
702757 return 0 ;
703758}
704759
760+ /* Get RSS configuration */
761+ static int otx2_get_rxfh (struct net_device * dev , u32 * indir ,
762+ u8 * hkey , u8 * hfunc )
763+ {
764+ return otx2_get_rxfh_context (dev , indir , hkey , hfunc ,
765+ DEFAULT_RSS_CONTEXT_GROUP );
766+ }
767+
768+ /* Configure RSS table and hash key */
769+ static int otx2_set_rxfh (struct net_device * dev , const u32 * indir ,
770+ const u8 * hkey , const u8 hfunc )
771+ {
772+
773+ u32 rss_context = DEFAULT_RSS_CONTEXT_GROUP ;
774+
775+ return otx2_set_rxfh_context (dev , indir , hkey , hfunc , & rss_context , 0 );
776+ }
777+
705778static u32 otx2_get_msglevel (struct net_device * netdev )
706779{
707780 struct otx2_nic * pfvf = netdev_priv (netdev );
@@ -771,6 +844,8 @@ static const struct ethtool_ops otx2_ethtool_ops = {
771844 .get_rxfh_indir_size = otx2_get_rxfh_indir_size ,
772845 .get_rxfh = otx2_get_rxfh ,
773846 .set_rxfh = otx2_set_rxfh ,
847+ .get_rxfh_context = otx2_get_rxfh_context ,
848+ .set_rxfh_context = otx2_set_rxfh_context ,
774849 .get_msglevel = otx2_get_msglevel ,
775850 .set_msglevel = otx2_set_msglevel ,
776851 .get_pauseparam = otx2_get_pauseparam ,
@@ -866,6 +941,8 @@ static const struct ethtool_ops otx2vf_ethtool_ops = {
866941 .get_rxfh_indir_size = otx2_get_rxfh_indir_size ,
867942 .get_rxfh = otx2_get_rxfh ,
868943 .set_rxfh = otx2_set_rxfh ,
944+ .get_rxfh_context = otx2_get_rxfh_context ,
945+ .set_rxfh_context = otx2_set_rxfh_context ,
869946 .get_ringparam = otx2_get_ringparam ,
870947 .set_ringparam = otx2_set_ringparam ,
871948 .get_coalesce = otx2_get_coalesce ,
0 commit comments