Skip to content

Commit a515e5b

Browse files
sgoutham-marvelldavem330
authored andcommitted
octeontx2-pf: Add check for non zero mcam flows
This patch ensures that mcam flows are allocated before adding or destroying the flows. Signed-off-by: Sunil Goutham <[email protected]> Signed-off-by: Subbaraya Sundeep <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fa16ee7 commit a515e5b

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -972,6 +972,12 @@ int otx2_add_flow(struct otx2_nic *pfvf, struct ethtool_rxnfc *nfc)
972972
int err = 0;
973973
u32 ring;
974974

975+
if (!flow_cfg->max_flows) {
976+
netdev_err(pfvf->netdev,
977+
"Ntuple rule count is 0, allocate and retry\n");
978+
return -EINVAL;
979+
}
980+
975981
ring = ethtool_get_flow_spec_ring(fsp->ring_cookie);
976982
if (!(pfvf->flags & OTX2_FLAG_NTUPLE_SUPPORT))
977983
return -ENOMEM;
@@ -1183,6 +1189,9 @@ int otx2_destroy_ntuple_flows(struct otx2_nic *pfvf)
11831189
if (!(pfvf->flags & OTX2_FLAG_NTUPLE_SUPPORT))
11841190
return 0;
11851191

1192+
if (!flow_cfg->max_flows)
1193+
return 0;
1194+
11861195
mutex_lock(&pfvf->mbox.lock);
11871196
req = otx2_mbox_alloc_msg_npc_delete_flow(&pfvf->mbox);
11881197
if (!req) {

drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1860,6 +1860,22 @@ static int otx2_set_features(struct net_device *netdev,
18601860
if ((changed & NETIF_F_NTUPLE) && !ntuple)
18611861
otx2_destroy_ntuple_flows(pf);
18621862

1863+
if ((changed & NETIF_F_NTUPLE) && ntuple) {
1864+
if (!pf->flow_cfg->max_flows) {
1865+
netdev_err(netdev,
1866+
"Can't enable NTUPLE, MCAM entries not allocated\n");
1867+
return -EINVAL;
1868+
}
1869+
}
1870+
1871+
if ((changed & NETIF_F_HW_TC) && tc) {
1872+
if (!pf->flow_cfg->max_flows) {
1873+
netdev_err(netdev,
1874+
"Can't enable TC, MCAM entries not allocated\n");
1875+
return -EINVAL;
1876+
}
1877+
}
1878+
18631879
if ((changed & NETIF_F_HW_TC) && !tc &&
18641880
pf->flow_cfg && pf->flow_cfg->nr_flows) {
18651881
netdev_err(netdev, "Can't disable TC hardware offload while flows are active\n");

0 commit comments

Comments
 (0)