octeontx2-pf: Add TC feature for VFs
Subsystems (4)
Subbaraya Sundeep
maintainerPATCH 1/1 octeontx2-pf: Add TC feature for VFs
This patch adds TC feature for VFs also. When MCAM rules are allocated for a VF then either TC or ntuple filters can be used. Below are the commands to use TC feature for a VF(say lbk0):
devlink dev param set pci/0002:01:00.1 name mcam_count value 16 \
cmode runtime
ethtool -K lbk0 hw-tc-offload on
ifconfig lbk0 up
tc qdisc add dev lbk0 ingress
tc filter add dev lbk0 parent ffff: protocol ip flower skip_sw \
dst_mac 98:03:9b:83:aa:12 action police rate 100Mbit burst 5000
Also to modify any fields of the hardware context with NIX_AQ_INSTOP_WRITE command then corresponding masks of those fields must be set as per hardware. This was missing in ingress ratelimiting context. This patch sets those masks also.
--- .../net/ethernet/marvell/octeontx2/af/rvu_nix.c | 1 + .../ethernet/marvell/octeontx2/nic/otx2_common.c | 50 ++++++++++++++++++++++ .../ethernet/marvell/octeontx2/nic/otx2_common.h | 2 + .../net/ethernet/marvell/octeontx2/nic/otx2_pf.c | 43 +------------------ .../net/ethernet/marvell/octeontx2/nic/otx2_tc.c | 5 ++- .../net/ethernet/marvell/octeontx2/nic/otx2_vf.c | 30 +++++-------- 6 files changed, 69 insertions(+), 62 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +1 -0
@@ -5312,6 +5312,7 @@ int rvu_nix_setup_ratelimit_aggr(struct rvu *rvu, u16 pcifunc, aq_req.ctype =NIX_AQ_CTYPE_BANDPROF ; aq_req.op =NIX_AQ_INSTOP_WRITE ;memcpy (&aq_req.prof, &aq_rsp.prof,sizeof (struct nix_bandprof_s )); +memset ((char *)&aq_req.prof_mask,0xff ,sizeof (struct nix_bandprof_s ));/* Clear higher layer enable bit in the mid profile, just in case */ aq_req.prof.hl_en =0 ; aq_req.prof_mask.hl_en =1 ;
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +50 -0
56 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +2 -0
@@ -871,6 +871,8 @@ int otx2_enable_rxvlan(struct otx2_nic *pf, bool enable);int otx2_install_rxvlan_offload_flow (struct otx2_nic *pfvf);bool otx2_xdp_sq_append_pkt (struct otx2_nic *pfvf,u64 iova,int len,u16 qidx);u16 otx2_get_max_mtu (struct otx2_nic *pfvf); +int otx2_handle_ntuple_tc_features (struct net_device *netdev, +netdev_features_t features);/* tc support */ int otx2_init_tc (struct otx2_nic *nic);void otx2_shutdown_tc (struct otx2_nic *nic);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +1 -42
56 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_tc.c +4 -1
@@ -58,7 +58,7 @@ int otx2_tc_alloc_ent_bitmap(struct otx2_nic *nic) {struct otx2_tc_info *tc = &nic->tc_info; -if (!nic->flow_cfg->max_flows ||is_otx2_vf (nic->pcifunc)) +if (!nic->flow_cfg->max_flows)return 0 ;/* Max flows changed, free the existing bitmap */
@@ -1023,6 +1023,7 @@ int otx2_setup_tc(struct net_device *netdev, enum tc_setup_type type,return -EOPNOTSUPP ; } } +EXPORT_SYMBOL (otx2_setup_tc);static const struct rhashtable_params tc_flow_ht_params = { .head_offset = offsetof(struct otx2_tc_flow , node),
@@ -1052,6 +1053,7 @@ int otx2_init_tc(struct otx2_nic *nic) tc->flow_ht_params = tc_flow_ht_params;return rhashtable_init (&tc->flow_table, &tc->flow_ht_params); } +EXPORT_SYMBOL (otx2_init_tc);void otx2_shutdown_tc (struct otx2_nic *nic) {
@@ -1060,3 +1062,4 @@ void otx2_shutdown_tc(struct otx2_nic *nic)kfree (tc->tc_entries_bitmap);rhashtable_destroy (&tc->flow_table); } +EXPORT_SYMBOL (otx2_shutdown_tc);
drivers/net/ethernet/marvell/octeontx2/nic/otx2_vf.c +11 -19
@@ -472,23 +472,7 @@ static void otx2vf_reset_task(struct work_struct *work)static int otx2vf_set_features (struct net_device *netdev,netdev_features_t features) { -netdev_features_t changed = features ^ netdev->features; -bool ntuple_enabled = !!(features &NETIF_F_NTUPLE ); -struct otx2_nic *vf =netdev_priv (netdev); - -if (changed &NETIF_F_NTUPLE ) { -if (!ntuple_enabled) { -otx2_mcam_flow_del (vf); -return 0 ; - } - -if (!otx2_get_maxflows (vf->flow_cfg)) { -netdev_err (netdev, -"Can't enable NTUPLE, MCAM entries not allocated\n" ); -return -EINVAL ; - } - } -return 0 ; +return otx2_handle_ntuple_tc_features (netdev, features); }static const struct net_device_ops otx2vf_netdev_ops = {
@@ -502,6 +486,7 @@ static const struct net_device_ops otx2vf_netdev_ops = { .ndo_get_stats64 = otx2_get_stats64, .ndo_tx_timeout = otx2_tx_timeout, .ndo_eth_ioctl = otx2_ioctl, + .ndo_setup_tc = otx2_setup_tc, };static int otx2_wq_init (struct otx2_nic *vf)
@@ -663,6 +648,7 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id) netdev->hw_features |=NETIF_F_NTUPLE ; netdev->hw_features |=NETIF_F_RXALL ; + netdev->hw_features |=NETIF_F_HW_TC ;netif_set_gso_max_segs (netdev,OTX2_MAX_GSO_SEGS ); netdev->watchdog_timeo =OTX2_TX_TIMEOUT ;
@@ -698,18 +684,24 @@ static int otx2vf_probe(struct pci_dev *pdev, const struct pci_device_id *id)if (err) goto err_unreg_netdev; - err =otx2_register_dl (vf); + err =otx2_init_tc (vf);if (err) goto err_unreg_netdev; + err =otx2_register_dl (vf); +if (err) + goto err_shutdown_tc; +#ifdef CONFIG_DCB err =otx2_dcbnl_set_ops (netdev);if (err) - goto err_unreg_netdev; + goto err_shutdown_tc;#endif return 0 ; +err_shutdown_tc: +otx2_shutdown_tc (vf); err_unreg_netdev:unregister_netdev (netdev); err_ptp_destroy:
Signature · 1 line
2.7.4
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (master) by David S. Miller <[email protected]>:
Quoted 13 lines · On Thu, 10 Feb 2022 17:21:44 +0530 you wrote:
This patch adds TC feature for VFs also. When MCAM rules are allocated for a VF then either TC or ntuple filters can be used. Below are the commands to use TC feature for a VF(say lbk0):
devlink dev param set pci/0002:01:00.1 name
mcam_countvalue 16 \
cmode runtime
ethtool -K lbk0 hw-tc-offload on
ifconfig lbk0 up
tc qdisc add dev lbk0 ingress
tc filter add dev lbk0 parent ffff: protocol ip flowerskip_sw\
dst_mac98:03:9b:83:aa:12 action police rate 100Mbit burst 5000
Quoted 1 line
[...]
Here is the summary with links:
- [net-next] octeontx2-pf: Add TC feature for VFs
https://git.kernel.org/netdev/net-next/c/4b0385bc8e6a
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html