Skip to content

Commit b53b2e2

Browse files
hechaoyongferruhy
authored andcommitted
net/nfp: support different configuration BAR size
A new NIC is introduced with different configuration BAR size other than 32K, and this is distinguished by the application firmware's class version ABI. Signed-off-by: Chaoyong He <[email protected]> Reviewed-by: Long Wu <[email protected]>
1 parent 1606952 commit b53b2e2

File tree

7 files changed

+59
-14
lines changed

7 files changed

+59
-14
lines changed

drivers/common/nfp/nfp_common_ctrl.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
*
1212
* On the NFP6000, due to THB-350, the configuration BAR is 32K in size.
1313
*/
14-
#define NFP_NET_CFG_BAR_SZ (32 * 1024)
14+
#define NFP_NET_CFG_BAR_SZ_32K (32 * 1024)
15+
#define NFP_NET_CFG_BAR_SZ_8K (8 * 1024)
16+
#define NFP_NET_CFG_BAR_SZ_MIN NFP_NET_CFG_BAR_SZ_8K
1517

1618
/*
1719
* Configuration sriov VF.
@@ -121,6 +123,10 @@
121123
struct nfp_net_fw_ver {
122124
uint8_t minor;
123125
uint8_t major;
126+
/**
127+
* BIT0: class, refer NFP_NET_CFG_VERSION_CLASS_*
128+
* BIT[7:1]: reserved
129+
*/
124130
uint8_t class;
125131
/**
126132
* This byte can be extended for more use.
@@ -147,6 +153,8 @@ struct nfp_net_fw_ver {
147153
#define NFP_NET_CFG_VERSION 0x0030
148154
#define NFP_NET_CFG_VERSION_DP_NFD3 0
149155
#define NFP_NET_CFG_VERSION_DP_NFDK 1
156+
#define NFP_NET_CFG_VERSION_CLASS_GENERIC 0
157+
#define NFP_NET_CFG_VERSION_CLASS_NO_EMEM 1
150158
#define NFP_NET_CFG_STS 0x0034
151159
#define NFP_NET_CFG_STS_LINK (0x1 << 0) /* Link up or down */
152160
/* Link rate */

drivers/net/nfp/flower/nfp_flower.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,7 @@ nfp_init_app_fw_flower(struct nfp_net_hw_priv *hw_priv)
692692
/* Map the PF ctrl bar */
693693
snprintf(bar_name, sizeof(bar_name), "_pf%u_net_bar0", id);
694694
pf_dev->ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, bar_name,
695-
NFP_NET_CFG_BAR_SZ, &pf_dev->ctrl_area);
695+
pf_dev->ctrl_bar_size, &pf_dev->ctrl_area);
696696
if (pf_dev->ctrl_bar == NULL) {
697697
PMD_INIT_LOG(ERR, "Cloud not map the PF vNIC ctrl bar");
698698
ret = -ENODEV;
@@ -737,7 +737,7 @@ nfp_init_app_fw_flower(struct nfp_net_hw_priv *hw_priv)
737737
/* Map the ctrl vNIC ctrl bar */
738738
snprintf(ctrl_name, sizeof(ctrl_name), "_pf%u_net_ctrl_bar", id);
739739
ctrl_hw->super.ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, ctrl_name,
740-
NFP_NET_CFG_BAR_SZ, &ctrl_hw->ctrl_area);
740+
pf_dev->ctrl_bar_size, &ctrl_hw->ctrl_area);
741741
if (ctrl_hw->super.ctrl_bar == NULL) {
742742
PMD_INIT_LOG(ERR, "Cloud not map the ctrl vNIC ctrl bar");
743743
ret = -ENODEV;

drivers/net/nfp/nfp_ethdev.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev,
10231023
if (pf_dev->multi_pf.enabled)
10241024
hw->ctrl_bar = pf_dev->ctrl_bar;
10251025
else
1026-
hw->ctrl_bar = pf_dev->ctrl_bar + (port * NFP_NET_CFG_BAR_SZ);
1026+
hw->ctrl_bar = pf_dev->ctrl_bar + (port * pf_dev->ctrl_bar_size);
10271027

10281028
net_hw->mac_stats = pf_dev->mac_stats_bar +
10291029
(net_hw->nfp_idx * NFP_MAC_STATS_SIZE);
@@ -1556,9 +1556,10 @@ nfp_enable_multi_pf(struct nfp_pf_dev *pf_dev)
15561556
memset(&net_hw, 0, sizeof(struct nfp_net_hw));
15571557

15581558
/* Map the symbol table */
1559+
pf_dev->ctrl_bar_size = NFP_NET_CFG_BAR_SZ_MIN;
15591560
snprintf(name, sizeof(name), "_pf%u_net_bar0",
15601561
pf_dev->multi_pf.function_id);
1561-
ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, name, NFP_NET_CFG_BAR_SZ,
1562+
ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, name, pf_dev->ctrl_bar_size,
15621563
&area);
15631564
if (ctrl_bar == NULL) {
15641565
PMD_INIT_LOG(ERR, "Failed to find data vNIC memory symbol");
@@ -1575,6 +1576,9 @@ nfp_enable_multi_pf(struct nfp_pf_dev *pf_dev)
15751576
goto end;
15761577
}
15771578

1579+
/* Set the ctrl bar size */
1580+
nfp_net_ctrl_bar_size_set(pf_dev);
1581+
15781582
if (!pf_dev->multi_pf.enabled)
15791583
goto end;
15801584

@@ -1671,7 +1675,7 @@ nfp_init_app_fw_nic(struct nfp_net_hw_priv *hw_priv)
16711675
/* Map the symbol table */
16721676
snprintf(bar_name, sizeof(bar_name), "_pf%u_net_bar0", id);
16731677
pf_dev->ctrl_bar = nfp_rtsym_map(pf_dev->sym_tbl, bar_name,
1674-
pf_dev->total_phyports * NFP_NET_CFG_BAR_SZ,
1678+
pf_dev->total_phyports * pf_dev->ctrl_bar_size,
16751679
&pf_dev->ctrl_area);
16761680
if (pf_dev->ctrl_bar == NULL) {
16771681
PMD_INIT_LOG(ERR, "nfp_rtsym_map fails for %s", bar_name);
@@ -2066,11 +2070,11 @@ nfp_net_vf_config_init(struct nfp_pf_dev *pf_dev)
20662070
if (pf_dev->sriov_vf == 0)
20672071
return 0;
20682072

2069-
min_size = NFP_NET_CFG_BAR_SZ * pf_dev->sriov_vf;
2073+
min_size = pf_dev->ctrl_bar_size * pf_dev->sriov_vf;
20702074
snprintf(vf_bar_name, sizeof(vf_bar_name), "_pf%d_net_vf_bar",
20712075
pf_dev->multi_pf.function_id);
20722076
pf_dev->vf_bar = nfp_rtsym_map_offset(pf_dev->sym_tbl, vf_bar_name,
2073-
NFP_NET_CFG_BAR_SZ * pf_dev->vf_base_id,
2077+
pf_dev->ctrl_bar_size * pf_dev->vf_base_id,
20742078
min_size, &pf_dev->vf_area);
20752079
if (pf_dev->vf_bar == NULL) {
20762080
PMD_INIT_LOG(ERR, "Failed to get vf cfg.");
@@ -2296,15 +2300,15 @@ nfp_pf_init(struct rte_pci_device *pci_dev)
22962300
goto hwqueues_cleanup;
22972301
}
22982302

2303+
ret = nfp_enable_multi_pf(pf_dev);
2304+
if (ret != 0)
2305+
goto mac_stats_cleanup;
2306+
22992307
ret = nfp_net_vf_config_init(pf_dev);
23002308
if (ret != 0) {
23012309
PMD_INIT_LOG(ERR, "Failed to init VF config.");
2302-
goto mac_stats_cleanup;
2303-
}
2304-
2305-
ret = nfp_enable_multi_pf(pf_dev);
2306-
if (ret != 0)
23072310
goto vf_cfg_tbl_cleanup;
2311+
}
23082312

23092313
hw_priv->is_pf = true;
23102314
hw_priv->pf_dev = pf_dev;

drivers/net/nfp/nfp_ethdev_vf.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
295295
goto pf_dev_free;
296296
}
297297

298+
/* Set the ctrl bar size */
299+
nfp_net_ctrl_bar_size_set(pf_dev);
300+
298301
PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar);
299302

300303
err = nfp_net_common_init(pf_dev, net_hw);

drivers/net/nfp/nfp_net_common.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2224,6 +2224,9 @@ nfp_net_version_check(struct nfp_hw *hw,
22242224
if (!nfp_net_is_valid_nfd_version(pf_dev->ver))
22252225
return false;
22262226

2227+
if (!nfp_net_is_valid_version_class(pf_dev->ver))
2228+
return false;
2229+
22272230
return true;
22282231
}
22292232

@@ -2365,6 +2368,28 @@ nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version)
23652368
return false;
23662369
}
23672370

2371+
bool
2372+
nfp_net_is_valid_version_class(struct nfp_net_fw_ver version)
2373+
{
2374+
switch (version.class) {
2375+
case NFP_NET_CFG_VERSION_CLASS_GENERIC:
2376+
return true;
2377+
case NFP_NET_CFG_VERSION_CLASS_NO_EMEM:
2378+
return true;
2379+
default:
2380+
return false;
2381+
}
2382+
}
2383+
2384+
void
2385+
nfp_net_ctrl_bar_size_set(struct nfp_pf_dev *pf_dev)
2386+
{
2387+
if (pf_dev->ver.class == NFP_NET_CFG_VERSION_CLASS_GENERIC)
2388+
pf_dev->ctrl_bar_size = NFP_NET_CFG_BAR_SZ_32K;
2389+
else
2390+
pf_dev->ctrl_bar_size = NFP_NET_CFG_BAR_SZ_8K;
2391+
}
2392+
23682393
/* Disable rx and tx functions to allow for reconfiguring. */
23692394
int
23702395
nfp_net_stop(struct rte_eth_dev *dev)

drivers/net/nfp/nfp_net_common.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ struct nfp_pf_dev {
117117
struct nfp_eth_table *nfp_eth_table;
118118

119119
uint8_t *ctrl_bar;
120+
uint32_t ctrl_bar_size;
120121

121122
struct nfp_cpp *cpp;
122123
struct nfp_cpp_area *ctrl_area;
@@ -354,6 +355,7 @@ void nfp_net_tx_desc_limits(struct nfp_net_hw_priv *hw_priv,
354355
int nfp_net_check_dma_mask(struct nfp_pf_dev *pf_dev, char *name);
355356
int nfp_net_firmware_version_get(struct rte_eth_dev *dev, char *fw_version, size_t fw_size);
356357
bool nfp_net_is_valid_nfd_version(struct nfp_net_fw_ver version);
358+
bool nfp_net_is_valid_version_class(struct nfp_net_fw_ver version);
357359
struct nfp_net_hw *nfp_net_get_hw(const struct rte_eth_dev *dev);
358360
int nfp_net_stop(struct rte_eth_dev *dev);
359361
int nfp_net_flow_ctrl_get(struct rte_eth_dev *dev,
@@ -380,6 +382,7 @@ int nfp_net_vf_config_app_init(struct nfp_net_hw *net_hw,
380382
struct nfp_pf_dev *pf_dev);
381383
bool nfp_net_version_check(struct nfp_hw *hw,
382384
struct nfp_pf_dev *pf_dev);
385+
void nfp_net_ctrl_bar_size_set(struct nfp_pf_dev *pf_dev);
383386

384387
#define NFP_PRIV_TO_APP_FW_NIC(app_fw_priv)\
385388
((struct nfp_app_fw_nic *)app_fw_priv)

drivers/net/nfp/nfp_net_ctrl.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,15 @@ nfp_net_tlv_caps_parse(struct rte_eth_dev *dev)
3030
uint32_t tlv_type;
3131
struct nfp_net_hw *net_hw;
3232
struct nfp_net_tlv_caps *caps;
33+
struct nfp_net_hw_priv *hw_priv;
3334

3435
net_hw = dev->data->dev_private;
36+
hw_priv = dev->process_private;
3537
caps = &net_hw->tlv_caps;
3638
nfp_net_tlv_caps_reset(caps);
3739

3840
data = net_hw->super.ctrl_bar + NFP_NET_CFG_TLV_BASE;
39-
end = net_hw->super.ctrl_bar + NFP_NET_CFG_BAR_SZ;
41+
end = net_hw->super.ctrl_bar + hw_priv->pf_dev->ctrl_bar_size;
4042

4143
hdr = rte_read32(data);
4244
if (hdr == 0) {

0 commit comments

Comments
 (0)