PF and VF NIX LFs that share a CGX LMAC reuse the same hardware PKIND programming. When HiGig2 or EDSA parsing is enabled, a VF NIX LF alloc must not reset the LMAC RX PKIND or default TX parse config over the PF setup. Add cgx_get_pkind() and rvu_cgx_is_pkind_config_permitted() so VFs skip cgx_set_pkind(), rvu_npc_set_pkind(), and NIX_AF_LFX_TX_PARSE_CFG updates when the LMAC is using NPC_RX_HIGIG_PKIND or NPC_RX_EDSA_PKIND.
Unified · Split
| @@ -518,6 +518,18 @@ int cgx_set_pkind(void *cgxd, u8 lmac_id, int pkind) · 517 unmodified lines | |||
| 518 | return 0; | 518 | return 0; |
| 519 | } | 519 | } |
| 520 | 520 | ||
| 521 | int cgx_get_pkind(void *cgxd, u8 lmac_id, int *pkind) | ||
| 522 | { | ||
| 523 | struct cgx *cgx = cgxd; | ||
| 524 | |||
| 525 | if (!is_lmac_valid(cgx, lmac_id)) | ||
| 526 | return -ENODEV; | ||
| 527 | |||
| 528 | *pkind = cgx_read(cgx, lmac_id, cgx->mac_ops->rxid_map_offset); | ||
| 529 | *pkind = *pkind & 0x3F; | ||
| 530 | return 0; | ||
| 531 | } | ||
| 532 | |||
| 521 | static u8 cgx_get_lmac_type(void *cgxd, int lmac_id) | 533 | static u8 cgx_get_lmac_type(void *cgxd, int lmac_id) |
| 522 | { | 534 | { |
| 523 | struct cgx *cgx = cgxd; | 535 | struct cgx *cgx = cgxd; |
| @@ -141,6 +141,7 @@ int cgx_get_cgxid(void *cgxd); · 140 unmodified lines | |||
| 141 | int cgx_get_lmac_cnt(void *cgxd); | 141 | int cgx_get_lmac_cnt(void *cgxd); |
| 142 | void *cgx_get_pdata(int cgx_id); | 142 | void *cgx_get_pdata(int cgx_id); |
| 143 | int cgx_set_pkind(void *cgxd, u8 lmac_id, int pkind); | 143 | int cgx_set_pkind(void *cgxd, u8 lmac_id, int pkind); |
| 144 | int cgx_get_pkind(void *cgxd, u8 lmac_id, int *pkind); | ||
| 144 | int cgx_lmac_evh_register(struct cgx_event_cb *cb, void *cgxd, int lmac_id); | 145 | int cgx_lmac_evh_register(struct cgx_event_cb *cb, void *cgxd, int lmac_id); |
| 145 | int cgx_lmac_evh_unregister(void *cgxd, int lmac_id); | 146 | int cgx_lmac_evh_unregister(void *cgxd, int lmac_id); |
| 146 | int cgx_get_tx_stats(void *cgxd, int lmac_id, int idx, u64 *tx_stat); | 147 | int cgx_get_tx_stats(void *cgxd, int lmac_id, int idx, u64 *tx_stat); |
| @@ -1115,6 +1115,8 @@ void npc_read_mcam_entry(struct rvu *rvu, struct npc_mcam *mcam, · 1114 unmodified lines | |||
| 1115 | u8 *intf, u8 *ena); | 1115 | u8 *intf, u8 *ena); |
| 1116 | int npc_config_cntr_default_entries(struct rvu *rvu, bool enable); | 1116 | int npc_config_cntr_default_entries(struct rvu *rvu, bool enable); |
| 1117 | bool is_cgx_config_permitted(struct rvu *rvu, u16 pcifunc); | 1117 | bool is_cgx_config_permitted(struct rvu *rvu, u16 pcifunc); |
| 1118 | bool rvu_cgx_check_permission_and_set_pkind(struct rvu *rvu, u16 pcifunc, int pkind); | ||
| 1119 | bool rvu_cgx_is_pkind_config_permitted(struct rvu *rvu, u16 pcifunc); | ||
| 1118 | bool is_mac_feature_supported(struct rvu *rvu, int pf, int feature); | 1120 | bool is_mac_feature_supported(struct rvu *rvu, int pf, int feature); |
| 1119 | u32 rvu_cgx_get_fifolen(struct rvu *rvu); | 1121 | u32 rvu_cgx_get_fifolen(struct rvu *rvu); |
| 1120 | void *rvu_first_cgx_pdata(struct rvu *rvu); | 1122 | void *rvu_first_cgx_pdata(struct rvu *rvu); |
| @@ -1355,3 +1355,82 @@ void rvu_mac_reset(struct rvu *rvu, u16 pcifunc) · 1354 unmodified lines | |||
| 1355 | if (mac_ops->mac_reset(cgxd, lmac, !is_vf(pcifunc))) | 1355 | if (mac_ops->mac_reset(cgxd, lmac, !is_vf(pcifunc))) |
| 1356 | dev_err(rvu->dev, "Failed to reset MAC\n"); | 1356 | dev_err(rvu->dev, "Failed to reset MAC\n"); |
| 1357 | } | 1357 | } |
| 1358 | |||
| 1359 | /* Do not allow CGX-mapped VFs to overwrite PKIND when special parse kinds | ||
| 1360 | * (HiGig, EDSA, etc.) are in use on the shared LMAC. VFs must not program | ||
| 1361 | * NPC_TX_DEF_PKIND on NIX_AF_LFX_TX_PARSE_CFG in that case: the PF owns | ||
| 1362 | * parse mode and no separate NPC_TX_HIGIG_PKIND is installed on the VF LF. | ||
| 1363 | * TX-parse callers skip the write when denied; rvu_lf_reset() clears each LF | ||
| 1364 | * before alloc so the next permitted owner programs NPC_TX_DEF_PKIND. | ||
| 1365 | */ | ||
| 1366 | bool rvu_cgx_is_pkind_config_permitted(struct rvu *rvu, u16 pcifunc) | ||
| 1367 | { | ||
| 1368 | int pf, err, rxpkind; | ||
| 1369 | u8 cgx_id, lmac_id; | ||
| 1370 | void *cgxd; | ||
| 1371 | |||
| 1372 | pf = rvu_get_pf(rvu->pdev, pcifunc); | ||
| 1373 | |||
| 1374 | if (!(pcifunc & RVU_PFVF_FUNC_MASK)) | ||
| 1375 | return true; | ||
| 1376 | |||
| 1377 | if (!is_pf_cgxmapped(rvu, pf)) | ||
| 1378 | return true; | ||
| 1379 | |||
| 1380 | rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id); | ||
| 1381 | cgxd = rvu_cgx_pdata(cgx_id, rvu); | ||
| 1382 | err = cgx_get_pkind(cgxd, lmac_id, &rxpkind); | ||
| 1383 | if (err) | ||
| 1384 | return false; | ||
| 1385 | |||
| 1386 | switch (rxpkind) { | ||
| 1387 | case NPC_RX_HIGIG_PKIND: | ||
| 1388 | case NPC_RX_EDSA_PKIND: | ||
| 1389 | return false; | ||
| 1390 | default: | ||
| 1391 | return true; | ||
| 1392 | } | ||
| 1393 | } | ||
| 1394 | |||
| 1395 | /* Do not allow CGX-mapped VFs to overwrite PKIND when special parse kinds | ||
| 1396 | * (HiGig, EDSA, etc.) are in use on the shared LMAC. | ||
| 1397 | */ | ||
| 1398 | bool rvu_cgx_check_permission_and_set_pkind(struct rvu *rvu, u16 pcifunc, int pkind) | ||
| 1399 | { | ||
| 1400 | int pf, err, rxpkind; | ||
| 1401 | u8 cgx_id, lmac_id; | ||
| 1402 | struct cgx *cgxd; | ||
| 1403 | |||
| 1404 | pf = rvu_get_pf(rvu->pdev, pcifunc); | ||
| 1405 | |||
| 1406 | if (!is_pf_cgxmapped(rvu, pf)) | ||
| 1407 | return false; | ||
| 1408 | |||
| 1409 | rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id); | ||
| 1410 | cgxd = rvu_cgx_pdata(cgx_id, rvu); | ||
| 1411 | |||
| 1412 | mutex_lock(&cgxd->lock); | ||
| 1413 | if (!is_vf(pcifunc)) | ||
| 1414 | goto set; | ||
| 1415 | |||
| 1416 | err = cgx_get_pkind(cgxd, lmac_id, &rxpkind); | ||
| 1417 | if (err) | ||
| 1418 | goto err; | ||
| 1419 | |||
| 1420 | switch (rxpkind) { | ||
| 1421 | case NPC_RX_HIGIG_PKIND: | ||
| 1422 | case NPC_RX_EDSA_PKIND: | ||
| 1423 | goto err; | ||
| 1424 | default: | ||
| 1425 | break; | ||
| 1426 | } | ||
| 1427 | |||
| 1428 | set: | ||
| 1429 | cgx_set_pkind(rvu_cgx_pdata(cgx_id, rvu), lmac_id, pkind); | ||
| 1430 | mutex_unlock(&cgxd->lock); | ||
| 1431 | return true; | ||
| 1432 | |||
| 1433 | err: | ||
| 1434 | mutex_unlock(&cgxd->lock); | ||
| 1435 | return false; | ||
| 1436 | } | ||
| @@ -363,8 +363,8 @@ static int nix_interface_init(struct rvu *rvu, u16 pcifunc, int type, int nixlf, · 362 unmodified lines | |||
| 363 | pfvf->tx_chan_cnt = 1; | 363 | pfvf->tx_chan_cnt = 1; |
| 364 | rsp->tx_link = cgx_id * hw->lmac_per_cgx + lmac_id; | 364 | rsp->tx_link = cgx_id * hw->lmac_per_cgx + lmac_id; |
| 365 | 365 | ||
| 366 | cgx_set_pkind(rvu_cgx_pdata(cgx_id, rvu), lmac_id, pkind); | 366 | if (rvu_cgx_check_permission_and_set_pkind(rvu, pcifunc, pkind)) |
| 367 | rvu_npc_set_pkind(rvu, pkind, pfvf); | 367 | rvu_npc_set_pkind(rvu, pkind, pfvf); |
| 368 | break; | 368 | break; |
| 369 | case NIX_INTF_TYPE_LBK: | 369 | case NIX_INTF_TYPE_LBK: |
| 370 | vf = (pcifunc & RVU_PFVF_FUNC_MASK) - 1; | 370 | vf = (pcifunc & RVU_PFVF_FUNC_MASK) - 1; |
| @@ -1505,13 +1505,15 @@ int rvu_mbox_handler_nix_lf_alloc(struct rvu *rvu, · 1134 unmodified lines | |||
| 1505 | struct nix_lf_alloc_req *req, | 1505 | struct nix_lf_alloc_req *req, |
| 1506 | struct nix_lf_alloc_rsp *rsp) | 1506 | struct nix_lf_alloc_rsp *rsp) |
| 1507 | { | 1507 | { |
| 1508 | int nixlf, qints, hwctx_size, intf, rc = 0; | 1508 | int nixlf, qints, hwctx_size, intf, rc = 0, pf; |
| 1509 | u16 bcast, mcast, promisc, ucast; | 1509 | u16 bcast, mcast, promisc, ucast; |
| 1510 | struct rvu_hwinfo *hw = rvu->hw; | 1510 | struct rvu_hwinfo *hw = rvu->hw; |
| 1511 | u16 pcifunc = req->hdr.pcifunc; | 1511 | u16 pcifunc = req->hdr.pcifunc; |
| 1512 | u8 cgx_id = 0, lmac_id = 0; | ||
| 1512 | bool rules_created = false; | 1513 | bool rules_created = false; |
| 1513 | struct rvu_block *block; | 1514 | struct rvu_block *block; |
| 1514 | struct rvu_pfvf *pfvf; | 1515 | struct rvu_pfvf *pfvf; |
| 1516 | struct cgx *cgxd; | ||
| 1515 | u64 cfg, ctx_cfg; | 1517 | u64 cfg, ctx_cfg; |
| 1516 | int blkaddr; | 1518 | int blkaddr; |
| 1517 | 1519 | ||
| @@ -1685,8 +1687,20 @@ int rvu_mbox_handler_nix_lf_alloc(struct rvu *rvu, · 167 unmodified lines | |||
| 1685 | rvu_write64(rvu, blkaddr, NIX_AF_LFX_RX_CFG(nixlf), req->rx_cfg); | 1687 | rvu_write64(rvu, blkaddr, NIX_AF_LFX_RX_CFG(nixlf), req->rx_cfg); |
| 1686 | 1688 | ||
| 1687 | /* Configure pkind for TX parse config */ | 1689 | /* Configure pkind for TX parse config */ |
| 1690 | |||
| 1691 | pf = rvu_get_pf(rvu->pdev, pcifunc); | ||
| 1688 | cfg = NPC_TX_DEF_PKIND; | 1692 | cfg = NPC_TX_DEF_PKIND; |
| 1689 | rvu_write64(rvu, blkaddr, NIX_AF_LFX_TX_PARSE_CFG(nixlf), cfg); | 1693 | |
| 1694 | if (is_pf_cgxmapped(rvu, pf) && is_vf(pcifunc)) { | ||
| 1695 | rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id); | ||
| 1696 | cgxd = rvu_cgx_pdata(cgx_id, rvu); | ||
| 1697 | mutex_lock(&cgxd->lock); | ||
| 1698 | if (rvu_cgx_is_pkind_config_permitted(rvu, pcifunc)) | ||
| 1699 | rvu_write64(rvu, blkaddr, NIX_AF_LFX_TX_PARSE_CFG(nixlf), cfg); | ||
| 1700 | mutex_unlock(&cgxd->lock); | ||
| 1701 | } else { | ||
| 1702 | rvu_write64(rvu, blkaddr, NIX_AF_LFX_TX_PARSE_CFG(nixlf), cfg); | ||
| 1703 | } | ||
| 1690 | 1704 | ||
| 1691 | if (is_rep_dev(rvu, pcifunc)) { | 1705 | if (is_rep_dev(rvu, pcifunc)) { |
| 1692 | pfvf->tx_chan_base = RVU_SWITCH_LBK_CHAN; | 1706 | pfvf->tx_chan_base = RVU_SWITCH_LBK_CHAN; |
| @@ -19,6 +19,7 @@ · 18 unmodified lines | |||
| 19 | #include "cn20k/npc.h" | 19 | #include "cn20k/npc.h" |
| 20 | #include "rvu_npc.h" | 20 | #include "rvu_npc.h" |
| 21 | #include "cn20k/reg.h" | 21 | #include "cn20k/reg.h" |
| 22 | #include "lmac_common.h" | ||
| 22 | 23 | ||
| 23 | #define RSVD_MCAM_ENTRIES_PER_PF 3 /* Broadcast, Promisc and AllMulticast */ | 24 | #define RSVD_MCAM_ENTRIES_PER_PF 3 /* Broadcast, Promisc and AllMulticast */ |
| 24 | #define RSVD_MCAM_ENTRIES_PER_NIXLF 1 /* Ucast for LFs */ | 25 | #define RSVD_MCAM_ENTRIES_PER_NIXLF 1 /* Ucast for LFs */ |
| @@ -4200,10 +4201,11 @@ int rvu_npc_set_parse_mode(struct rvu *rvu, u16 pcifunc, u64 mode, u8 dir, · 4175 unmodified lines | |||
| 4200 | 4201 | ||
| 4201 | { | 4202 | { |
| 4202 | struct rvu_pfvf *pfvf = rvu_get_pfvf(rvu, pcifunc); | 4203 | struct rvu_pfvf *pfvf = rvu_get_pfvf(rvu, pcifunc); |
| 4203 | int blkaddr, nixlf, rc, intf_mode; | ||
| 4204 | int pf = rvu_get_pf(rvu->pdev, pcifunc); | 4204 | int pf = rvu_get_pf(rvu->pdev, pcifunc); |
| 4205 | int blkaddr, nixlf, rc, intf_mode; | ||
| 4206 | u8 cgx_id = 0, lmac_id = 0; | ||
| 4205 | u64 rxpkind, txpkind; | 4207 | u64 rxpkind, txpkind; |
| 4206 | u8 cgx_id, lmac_id; | 4208 | struct cgx *cgxd; |
| 4207 | 4209 | ||
| 4208 | /* use default pkind to disable edsa/higig */ | 4210 | /* use default pkind to disable edsa/higig */ |
| 4209 | rxpkind = rvu_npc_get_pkind(rvu, pf); | 4211 | rxpkind = rvu_npc_get_pkind(rvu, pf); |
| @@ -4227,12 +4229,8 @@ int rvu_npc_set_parse_mode(struct rvu *rvu, u16 pcifunc, u64 mode, u8 dir, · 17 unmodified lines | |||
| 4227 | /* rx pkind set req valid only for cgx mapped PFs */ | 4229 | /* rx pkind set req valid only for cgx mapped PFs */ |
| 4228 | if (!is_cgx_config_permitted(rvu, pcifunc)) | 4230 | if (!is_cgx_config_permitted(rvu, pcifunc)) |
| 4229 | return 0; | 4231 | return 0; |
| 4230 | rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, &lmac_id); | 4232 | if (!rvu_cgx_check_permission_and_set_pkind(rvu, pcifunc, rxpkind)) |
| 4231 | 4233 | return -EINVAL; | |
| 4232 | rc = cgx_set_pkind(rvu_cgx_pdata(cgx_id, rvu), lmac_id, | ||
| 4233 | rxpkind); | ||
| 4234 | if (rc) | ||
| 4235 | return rc; | ||
| 4236 | } | 4234 | } |
| 4237 | 4235 | ||
| 4238 | if (dir & PKIND_TX) { | 4236 | if (dir & PKIND_TX) { |
| @@ -4241,8 +4239,19 @@ int rvu_npc_set_parse_mode(struct rvu *rvu, u16 pcifunc, u64 mode, u8 dir, · 2 unmodified lines | |||
| 4241 | if (rc) | 4239 | if (rc) |
| 4242 | return rc; | 4240 | return rc; |
| 4243 | 4241 | ||
| 4244 | rvu_write64(rvu, blkaddr, NIX_AF_LFX_TX_PARSE_CFG(nixlf), | 4242 | if (is_pf_cgxmapped(rvu, pf) && is_vf(pcifunc)) { |
| 4245 | txpkind); | 4243 | rvu_get_cgx_lmac_id(rvu->pf2cgxlmac_map[pf], &cgx_id, |
| 4244 | &lmac_id); | ||
| 4245 | cgxd = rvu_cgx_pdata(cgx_id, rvu); | ||
| 4246 | mutex_lock(&cgxd->lock); | ||
| 4247 | if (rvu_cgx_is_pkind_config_permitted(rvu, pcifunc)) | ||
| 4248 | rvu_write64(rvu, blkaddr, NIX_AF_LFX_TX_PARSE_CFG(nixlf), | ||
| 4249 | txpkind); | ||
| 4250 | mutex_unlock(&cgxd->lock); | ||
| 4251 | } else { | ||
| 4252 | rvu_write64(rvu, blkaddr, NIX_AF_LFX_TX_PARSE_CFG(nixlf), | ||
| 4253 | txpkind); | ||
| 4254 | } | ||
| 4246 | } | 4255 | } |
| 4247 | 4256 | ||
| 4248 | pfvf->intf_mode = intf_mode; | 4257 | pfvf->intf_mode = intf_mode; |