@@ -650,7 +650,7 @@ nfp_flower_init_vnic_common(struct nfp_net_hw *hw, const char *vnic_type)
hw->rx_bar = pf_dev->hw_queues + rx_bar_off;
/* Get some of the read-only fields from the config BAR */
- hw->ver = nn_cfg_readl(hw, NFP_NET_CFG_VERSION);
+ nfp_net_cfg_read_version(hw);
hw->cap = nn_cfg_readl(hw, NFP_NET_CFG_CAP);
hw->max_mtu = nn_cfg_readl(hw, NFP_NET_CFG_MAX_MTU);
/* Set the current MTU to the maximum supported */
@@ -661,7 +661,7 @@ nfp_flower_init_vnic_common(struct nfp_net_hw *hw, const char *vnic_type)
return -ENODEV;
/* read the Rx offset configured from firmware */
- if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 2)
+ if (hw->ver.major < 2)
hw->rx_offset = NFP_NET_RX_OFFSET;
else
hw->rx_offset = nn_cfg_readl(hw, NFP_NET_CFG_RX_OFFSET_ADDR);
@@ -356,8 +356,7 @@ void
nfp_net_log_device_information(const struct nfp_net_hw *hw)
{
PMD_INIT_LOG(INFO, "VER: %u.%u, Maximum supported MTU: %d",
- NFD_CFG_MAJOR_VERSION_of(hw->ver),
- NFD_CFG_MINOR_VERSION_of(hw->ver), hw->max_mtu);
+ hw->ver.major, hw->ver.minor, hw->max_mtu);
PMD_INIT_LOG(INFO, "CAP: %#x, %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", hw->cap,
hw->cap & NFP_NET_CFG_CTRL_PROMISC ? "PROMISC " : "",
@@ -1114,14 +1113,14 @@ nfp_net_tx_desc_limits(struct nfp_net_hw *hw,
{
uint16_t tx_dpp;
- switch (NFD_CFG_CLASS_VER_of(hw->ver)) {
+ switch (hw->ver.extend) {
case NFP_NET_CFG_VERSION_DP_NFD3:
tx_dpp = NFD3_TX_DESC_PER_PKT;
break;
case NFP_NET_CFG_VERSION_DP_NFDK:
- if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 5) {
+ if (hw->ver.major < 5) {
PMD_DRV_LOG(ERR, "NFDK must use ABI 5 or newer, found: %d",
- NFD_CFG_MAJOR_VERSION_of(hw->ver));
+ hw->ver.major);
return -EINVAL;
}
tx_dpp = NFDK_TX_DESC_PER_SIMPLE_PKT;
@@ -1911,11 +1910,10 @@ nfp_net_set_vxlan_port(struct nfp_net_hw *hw,
int
nfp_net_check_dma_mask(struct nfp_net_hw *hw, char *name)
{
- if (NFD_CFG_CLASS_VER_of(hw->ver) == NFP_NET_CFG_VERSION_DP_NFD3 &&
+ if (hw->ver.extend == NFP_NET_CFG_VERSION_DP_NFD3 &&
rte_mem_check_dma_mask(40) != 0) {
- PMD_DRV_LOG(ERR,
- "The device %s can't be used: restricted dma mask to 40 bits!",
- name);
+ PMD_DRV_LOG(ERR, "Device %s can't be used: restricted dma mask to 40 bits!",
+ name);
return -ENODEV;
}
@@ -1930,7 +1928,7 @@ nfp_net_init_metadata_format(struct nfp_net_hw *hw)
* single metadata if only RSS(v1) is supported by hw capability, and RSS(v2)
* also indicate that we are using chained metadata.
*/
- if (NFD_CFG_MAJOR_VERSION_of(hw->ver) == 4) {
+ if (hw->ver.major == 4) {
hw->meta_format = NFP_NET_METAFORMAT_CHAINED;
} else if ((hw->cap & NFP_NET_CFG_CTRL_CHAIN_META) != 0) {
hw->meta_format = NFP_NET_METAFORMAT_CHAINED;
@@ -1944,3 +1942,15 @@ nfp_net_init_metadata_format(struct nfp_net_hw *hw)
hw->meta_format = NFP_NET_METAFORMAT_SINGLE;
}
}
+
+void
+nfp_net_cfg_read_version(struct nfp_net_hw *hw)
+{
+ union {
+ uint32_t whole;
+ struct nfp_net_fw_ver split;
+ } version;
+
+ version.whole = nn_cfg_readl(hw, NFP_NET_CFG_VERSION);
+ hw->ver = version.split;
+}
@@ -80,24 +80,6 @@ struct nfp_net_adapter;
#define NFP_NET_LINK_DOWN_CHECK_TIMEOUT 4000 /* ms */
#define NFP_NET_LINK_UP_CHECK_TIMEOUT 1000 /* ms */
-/* Version number helper defines */
-#define NFD_CFG_CLASS_VER_msk 0xff
-#define NFD_CFG_CLASS_VER_shf 24
-#define NFD_CFG_CLASS_VER(x) (((x) & 0xff) << 24)
-#define NFD_CFG_CLASS_VER_of(x) (((x) >> 24) & 0xff)
-#define NFD_CFG_CLASS_TYPE_msk 0xff
-#define NFD_CFG_CLASS_TYPE_shf 16
-#define NFD_CFG_CLASS_TYPE(x) (((x) & 0xff) << 16)
-#define NFD_CFG_CLASS_TYPE_of(x) (((x) >> 16) & 0xff)
-#define NFD_CFG_MAJOR_VERSION_msk 0xff
-#define NFD_CFG_MAJOR_VERSION_shf 8
-#define NFD_CFG_MAJOR_VERSION(x) (((x) & 0xff) << 8)
-#define NFD_CFG_MAJOR_VERSION_of(x) (((x) >> 8) & 0xff)
-#define NFD_CFG_MINOR_VERSION_msk 0xff
-#define NFD_CFG_MINOR_VERSION_shf 0
-#define NFD_CFG_MINOR_VERSION(x) (((x) & 0xff) << 0)
-#define NFD_CFG_MINOR_VERSION_of(x) (((x) >> 0) & 0xff)
-
/* Number of supported physical ports */
#define NFP_MAX_PHYPORTS 12
@@ -196,7 +178,7 @@ struct nfp_net_hw {
struct rte_eth_dev *eth_dev;
/* Info from the firmware */
- uint32_t ver;
+ struct nfp_net_fw_ver ver;
uint32_t cap;
uint32_t max_mtu;
uint32_t mtu;
@@ -490,6 +472,7 @@ int nfp_net_tx_desc_limits(struct nfp_net_hw *hw,
uint16_t *max_tx_desc);
int nfp_net_check_dma_mask(struct nfp_net_hw *hw, char *name);
void nfp_net_init_metadata_format(struct nfp_net_hw *hw);
+void nfp_net_cfg_read_version(struct nfp_net_hw *hw);
#define NFP_NET_DEV_PRIVATE_TO_HW(adapter)\
(&((struct nfp_net_adapter *)adapter)->hw)
@@ -130,6 +130,20 @@
#define NFP_NET_CFG_CTRL_CHAIN_META (NFP_NET_CFG_CTRL_RSS2 | \
NFP_NET_CFG_CTRL_CSUM_COMPLETE)
+
+/* Version number helper defines */
+struct nfp_net_fw_ver {
+ uint8_t minor;
+ uint8_t major;
+ uint8_t class;
+ /**
+ * This byte can be extended for more use.
+ * BIT0: NFD dp type, refer NFP_NET_CFG_VERSION_DP_NFDx
+ * BIT[7:1]: reserved
+ */
+ uint8_t extend;
+};
+
/*
* Read-only words (0x0030 - 0x0050):
* @NFP_NET_CFG_VERSION: Firmware version number
@@ -147,14 +161,6 @@
#define NFP_NET_CFG_VERSION 0x0030
#define NFP_NET_CFG_VERSION_DP_NFD3 0
#define NFP_NET_CFG_VERSION_DP_NFDK 1
-#define NFP_NET_CFG_VERSION_RESERVED_MASK (0xff << 24)
-#define NFP_NET_CFG_VERSION_CLASS_MASK (0xff << 16)
-#define NFP_NET_CFG_VERSION_CLASS(x) (((x) & 0xff) << 16)
-#define NFP_NET_CFG_VERSION_CLASS_GENERIC 0
-#define NFP_NET_CFG_VERSION_MAJOR_MASK (0xff << 8)
-#define NFP_NET_CFG_VERSION_MAJOR(x) (((x) & 0xff) << 8)
-#define NFP_NET_CFG_VERSION_MINOR_MASK (0xff << 0)
-#define NFP_NET_CFG_VERSION_MINOR(x) (((x) & 0xff) << 0)
#define NFP_NET_CFG_STS 0x0034
#define NFP_NET_CFG_STS_LINK (0x1 << 0) /* Link up or down */
/* Link rate */
@@ -466,14 +466,14 @@ static const struct eth_dev_ops nfp_net_eth_dev_ops = {
static inline int
nfp_net_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev)
{
- switch (NFD_CFG_CLASS_VER_of(hw->ver)) {
+ switch (hw->ver.extend) {
case NFP_NET_CFG_VERSION_DP_NFD3:
eth_dev->tx_pkt_burst = &nfp_net_nfd3_xmit_pkts;
break;
case NFP_NET_CFG_VERSION_DP_NFDK:
- if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 5) {
+ if (hw->ver.major < 5) {
PMD_DRV_LOG(ERR, "NFDK must use ABI 5 or newer, found: %d",
- NFD_CFG_MAJOR_VERSION_of(hw->ver));
+ hw->ver.major);
return -EINVAL;
}
eth_dev->tx_pkt_burst = &nfp_net_nfdk_xmit_pkts;
@@ -571,7 +571,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar);
PMD_INIT_LOG(DEBUG, "MAC stats: %p", hw->mac_stats);
- hw->ver = nn_cfg_readl(hw, NFP_NET_CFG_VERSION);
+ nfp_net_cfg_read_version(hw);
if (nfp_net_check_dma_mask(hw, pci_dev->name) != 0)
return -ENODEV;
@@ -629,7 +629,7 @@ nfp_net_init(struct rte_eth_dev *eth_dev)
nfp_net_init_metadata_format(hw);
- if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 2)
+ if (hw->ver.major < 2)
hw->rx_offset = NFP_NET_RX_OFFSET;
else
hw->rx_offset = nn_cfg_readl(hw, NFP_NET_CFG_RX_OFFSET_ADDR);
@@ -246,14 +246,14 @@ static const struct eth_dev_ops nfp_netvf_eth_dev_ops = {
static inline int
nfp_netvf_ethdev_ops_mount(struct nfp_net_hw *hw, struct rte_eth_dev *eth_dev)
{
- switch (NFD_CFG_CLASS_VER_of(hw->ver)) {
+ switch (hw->ver.extend) {
case NFP_NET_CFG_VERSION_DP_NFD3:
eth_dev->tx_pkt_burst = &nfp_net_nfd3_xmit_pkts;
break;
case NFP_NET_CFG_VERSION_DP_NFDK:
- if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 5) {
+ if (hw->ver.major < 5) {
PMD_DRV_LOG(ERR, "NFDK must use ABI 5 or newer, found: %d",
- NFD_CFG_MAJOR_VERSION_of(hw->ver));
+ hw->ver.major);
return -EINVAL;
}
eth_dev->tx_pkt_burst = &nfp_net_nfdk_xmit_pkts;
@@ -298,7 +298,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
PMD_INIT_LOG(DEBUG, "ctrl bar: %p", hw->ctrl_bar);
- hw->ver = nn_cfg_readl(hw, NFP_NET_CFG_VERSION);
+ nfp_net_cfg_read_version(hw);
if (nfp_net_check_dma_mask(hw, pci_dev->name) != 0)
return -ENODEV;
@@ -380,7 +380,7 @@ nfp_netvf_init(struct rte_eth_dev *eth_dev)
nfp_net_init_metadata_format(hw);
- if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 2)
+ if (hw->ver.major < 2)
hw->rx_offset = NFP_NET_RX_OFFSET;
else
hw->rx_offset = nn_cfg_readl(hw, NFP_NET_CFG_RX_OFFSET_ADDR);
@@ -764,14 +764,14 @@ nfp_net_tx_queue_setup(struct rte_eth_dev *dev,
hw = NFP_NET_DEV_PRIVATE_TO_HW(dev->data->dev_private);
- switch (NFD_CFG_CLASS_VER_of(hw->ver)) {
+ switch (hw->ver.extend) {
case NFP_NET_CFG_VERSION_DP_NFD3:
return nfp_net_nfd3_tx_queue_setup(dev, queue_idx,
nb_desc, socket_id, tx_conf);
case NFP_NET_CFG_VERSION_DP_NFDK:
- if (NFD_CFG_MAJOR_VERSION_of(hw->ver) < 5) {
+ if (hw->ver.major < 5) {
PMD_DRV_LOG(ERR, "NFDK must use ABI 5 or newer, found: %d",
- NFD_CFG_MAJOR_VERSION_of(hw->ver));
+ hw->ver.major);
return -EINVAL;
}
return nfp_net_nfdk_tx_queue_setup(dev, queue_idx,