@@ -1204,9 +1204,6 @@ extern const struct rte_flow_ops bnxt_flow_meter_ops;
} \
} while (0)
-#define BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev) \
- ((eth_dev)->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
-
extern int bnxt_logtype_driver;
#define RTE_LOGTYPE_BNXT bnxt_logtype_driver
#define PMD_DRV_LOG_RAW(level, fmt, args...) \
@@ -3525,7 +3525,7 @@ bnxt_flow_ops_get_op(struct rte_eth_dev *dev,
if (!bp)
return -EIO;
- if (BNXT_ETH_DEV_IS_REPRESENTOR(dev)) {
+ if (rte_eth_dev_is_repr(dev)) {
struct bnxt_representor *vfr = dev->data->dev_private;
bp = vfr->parent_dev->data->dev_private;
/* parent is deleted while children are still valid */
@@ -6781,7 +6781,7 @@ static int bnxt_pci_remove(struct rte_pci_device *pci_dev)
PMD_DRV_LOG(DEBUG, "BNXT Port:%d pci remove\n", eth_dev->data->port_id);
if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
- if (eth_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+ if (rte_eth_dev_is_repr(eth_dev))
return rte_eth_dev_destroy(eth_dev,
bnxt_representor_uninit);
else
@@ -202,7 +202,7 @@ bnxt_pmd_get_svif(uint16_t port_id, bool func_svif,
struct bnxt *bp;
eth_dev = &rte_eth_devices[port_id];
- if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) {
+ if (rte_eth_dev_is_repr(eth_dev)) {
struct bnxt_representor *vfr = eth_dev->data->dev_private;
if (!vfr)
return 0;
@@ -260,7 +260,7 @@ bnxt_pmd_get_vnic_id(uint16_t port, enum bnxt_ulp_intf_type type)
struct bnxt *bp;
eth_dev = &rte_eth_devices[port];
- if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) {
+ if (rte_eth_dev_is_repr(eth_dev)) {
struct bnxt_representor *vfr = eth_dev->data->dev_private;
if (!vfr)
return 0;
@@ -285,7 +285,7 @@ bnxt_pmd_get_fw_func_id(uint16_t port, enum bnxt_ulp_intf_type type)
struct bnxt *bp;
eth_dev = &rte_eth_devices[port];
- if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) {
+ if (rte_eth_dev_is_repr(eth_dev)) {
struct bnxt_representor *vfr = eth_dev->data->dev_private;
if (!vfr)
return 0;
@@ -308,7 +308,7 @@ bnxt_pmd_get_interface_type(uint16_t port)
struct bnxt *bp;
eth_dev = &rte_eth_devices[port];
- if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev))
+ if (rte_eth_dev_is_repr(eth_dev))
return BNXT_ULP_INTF_TYPE_VF_REP;
bp = eth_dev->data->dev_private;
@@ -330,7 +330,7 @@ bnxt_pmd_get_phy_port_id(uint16_t port_id)
struct bnxt *bp;
eth_dev = &rte_eth_devices[port_id];
- if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) {
+ if (rte_eth_dev_is_repr(eth_dev)) {
vfr = eth_dev->data->dev_private;
if (!vfr)
return 0;
@@ -350,7 +350,7 @@ bnxt_pmd_get_parif(uint16_t port_id, enum bnxt_ulp_intf_type type)
struct bnxt *bp;
eth_dev = &rte_eth_devices[port_id];
- if (BNXT_ETH_DEV_IS_REPRESENTOR(eth_dev)) {
+ if (rte_eth_dev_is_repr(eth_dev)) {
struct bnxt_representor *vfr = eth_dev->data->dev_private;
if (!vfr)
return 0;
@@ -1559,7 +1559,7 @@ bnxt_ulp_destroy_vfr_default_rules(struct bnxt *bp, bool global)
struct rte_eth_dev *vfr_eth_dev;
struct bnxt_representor *vfr_bp;
- if (!BNXT_TRUFLOW_EN(bp) || BNXT_ETH_DEV_IS_REPRESENTOR(bp->eth_dev))
+ if (!BNXT_TRUFLOW_EN(bp) || rte_eth_dev_is_repr(bp->eth_dev))
return;
if (!bp->ulp_ctx || !bp->ulp_ctx->cfg_data)
@@ -2316,7 +2316,7 @@ bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev *dev)
{
struct bnxt *bp = (struct bnxt *)dev->data->dev_private;
- if (BNXT_ETH_DEV_IS_REPRESENTOR(dev)) {
+ if (rte_eth_dev_is_repr(dev)) {
struct bnxt_representor *vfr = dev->data->dev_private;
bp = vfr->parent_dev->data->dev_private;
@@ -449,7 +449,7 @@ bnxt_ulp_destroy_df_rules(struct bnxt *bp, bool global)
uint16_t port_id;
if (!BNXT_TRUFLOW_EN(bp) ||
- BNXT_ETH_DEV_IS_REPRESENTOR(bp->eth_dev))
+ rte_eth_dev_is_repr(bp->eth_dev))
return;
if (!bp->ulp_ctx || !bp->ulp_ctx->cfg_data)
@@ -514,7 +514,7 @@ bnxt_ulp_create_df_rules(struct bnxt *bp)
int rc = 0;
if (!BNXT_TRUFLOW_EN(bp) ||
- BNXT_ETH_DEV_IS_REPRESENTOR(bp->eth_dev) || !bp->ulp_ctx)
+ rte_eth_dev_is_repr(bp->eth_dev) || !bp->ulp_ctx)
return 0;
port_id = bp->eth_dev->data->port_id;
@@ -339,7 +339,7 @@ cpfl_repr_link_update(struct rte_eth_dev *ethdev,
struct cpfl_vport_id vi;
int ret;
- if (!(ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)) {
+ if (!rte_eth_dev_is_repr(ethdev)) {
PMD_INIT_LOG(ERR, "This ethdev is not representor.");
return -EINVAL;
}
@@ -233,11 +233,6 @@ struct enic_vf_representor {
#define VF_ENIC_TO_VF_REP(vf_enic) \
container_of(vf_enic, struct enic_vf_representor, enic)
-static inline int enic_is_vf_rep(struct enic *enic)
-{
- return !!(enic->rte_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR);
-}
-
/* Compute ethdev's max packet size from MTU */
static inline uint32_t enic_mtu_to_max_rx_pktlen(uint32_t mtu)
{
@@ -1386,7 +1386,7 @@ static int eth_enic_pci_remove(struct rte_pci_device *pci_dev)
ethdev = rte_eth_dev_allocated(pci_dev->device.name);
if (!ethdev)
return -ENODEV;
- if (ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+ if (rte_eth_dev_is_repr(ethdev))
return rte_eth_dev_destroy(ethdev, enic_vf_representor_uninit);
else
return rte_eth_dev_destroy(ethdev, eth_enic_dev_uninit);
@@ -1535,14 +1535,14 @@ vf_egress_port_id_action(struct enic_flowman *fm,
ENICPMD_FUNC_TRACE();
src_enic = fm->user_enic;
dst_enic = pmd_priv(dst_dev);
- if (!(src_enic->rte_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)) {
+ if (!rte_eth_dev_is_repr(src_enic->rte_dev)) {
return rte_flow_error_set(error, EINVAL,
RTE_FLOW_ERROR_TYPE_ACTION,
NULL, "source port is not VF representor");
}
/* VF -> PF uplink. dst is not VF representor */
- if (!(dst_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)) {
+ if (!rte_eth_dev_is_repr(dst_dev)) {
/* PF is the VF's PF? Then nothing to do */
vf = VF_ENIC_TO_VF_REP(src_enic);
if (vf->pf == dst_enic) {
@@ -1954,7 +1954,7 @@ enic_fm_copy_action(struct enic_flowman *fm,
if (!(overlap & (FATE | PASSTHRU | COUNT | PORT_ID)))
goto unsupported;
/* Egress from VF: need implicit WQ match */
- if (enic_is_vf_rep(enic) && !ingress) {
+ if (rte_eth_dev_is_repr(enic->rte_dev) && !ingress) {
fmt->ftm_data.fk_wq_id = 0;
fmt->ftm_mask.fk_wq_id = 0xffff;
fmt->ftm_data.fk_wq_vnic = enic->fm_vnic_handle;
@@ -3226,7 +3226,7 @@ enic_fm_init(struct enic *enic)
return 0;
ENICPMD_FUNC_TRACE();
/* Get vnic handle and save for port-id action */
- if (enic_is_vf_rep(enic))
+ if (rte_eth_dev_is_repr(enic->rte_dev))
addr = &VF_ENIC_TO_VF_REP(enic)->bdf;
else
addr = &RTE_ETH_DEV_TO_PCI(enic->rte_dev)->addr;
@@ -3240,7 +3240,7 @@ enic_fm_init(struct enic *enic)
enic->fm_vnic_uif = vnic_dev_uif(enic->vdev);
ENICPMD_LOG(DEBUG, "uif %u", enic->fm_vnic_uif);
/* Nothing else to do for representor. It will share the PF flowman */
- if (enic_is_vf_rep(enic))
+ if (rte_eth_dev_is_repr(enic->rte_dev))
return 0;
fm = calloc(1, sizeof(*fm));
if (fm == NULL) {
@@ -3321,7 +3321,7 @@ enic_fm_destroy(struct enic *enic)
struct enic_fm_fet *fet;
ENICPMD_FUNC_TRACE();
- if (enic_is_vf_rep(enic)) {
+ if (rte_eth_dev_is_repr(enic->rte_dev)) {
delete_rep_flows(enic);
return;
}
@@ -3358,7 +3358,7 @@ enic_fm_allocate_switch_domain(struct enic *pf)
int ret;
ENICPMD_FUNC_TRACE();
- if (enic_is_vf_rep(pf))
+ if (rte_eth_dev_is_repr(pf->rte_dev))
return -EINVAL;
cur = pf;
cur_a = &RTE_ETH_DEV_TO_PCI(cur->rte_dev)->addr;
@@ -3367,7 +3367,7 @@ enic_fm_allocate_switch_domain(struct enic *pf)
dev = &rte_eth_devices[pid];
if (!dev_is_enic(dev))
continue;
- if (dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+ if (rte_eth_dev_is_repr(dev))
continue;
if (dev == cur->rte_dev)
continue;
@@ -3597,7 +3597,7 @@ delete_rep_flows(struct enic *enic)
struct rte_eth_dev *dev;
uint32_t i;
- RTE_ASSERT(enic_is_vf_rep(enic));
+ RTE_ASSERT(rte_eth_dev_is_repr(enic->rte_dev));
vf = VF_ENIC_TO_VF_REP(enic);
dev = vf->pf->rte_dev;
for (i = 0; i < ARRAY_SIZE(vf->vf2rep_flow); i++) {
@@ -3617,7 +3617,7 @@ begin_fm(struct enic *enic)
struct enic_flowman *fm;
/* Representor uses PF flowman */
- if (enic_is_vf_rep(enic)) {
+ if (rte_eth_dev_is_repr(enic->rte_dev)) {
vf = VF_ENIC_TO_VF_REP(enic);
fm = vf->pf->fm;
} else {
@@ -824,7 +824,7 @@ int enic_alloc_rq(struct enic *enic, uint16_t queue_idx,
* Representor uses a reserved PF queue. Translate representor
* queue number to PF queue number.
*/
- if (enic_is_vf_rep(enic)) {
+ if (rte_eth_dev_is_repr(enic->rte_dev)) {
RTE_ASSERT(queue_idx == 0);
vf = VF_ENIC_TO_VF_REP(enic);
sop_queue_idx = vf->pf_rq_sop_idx;
@@ -1053,7 +1053,7 @@ int enic_alloc_wq(struct enic *enic, uint16_t queue_idx,
* Representor uses a reserved PF queue. Translate representor
* queue number to PF queue number.
*/
- if (enic_is_vf_rep(enic)) {
+ if (rte_eth_dev_is_repr(enic->rte_dev)) {
RTE_ASSERT(queue_idx == 0);
vf = VF_ENIC_TO_VF_REP(enic);
queue_idx = vf->pf_wq_idx;
@@ -706,7 +706,7 @@ static int eth_i40e_pci_remove(struct rte_pci_device *pci_dev)
if (!ethdev)
return 0;
- if (ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+ if (rte_eth_dev_is_repr(ethdev))
return rte_eth_dev_pci_generic_remove(pci_dev,
i40e_vf_representor_uninit);
else
@@ -2131,7 +2131,7 @@ eth_ice_dcf_pci_remove(struct rte_pci_device *pci_dev)
if (!eth_dev)
return 0;
- if (eth_dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+ if (rte_eth_dev_is_repr(eth_dev))
return rte_eth_dev_pci_generic_remove(pci_dev,
ice_dcf_vf_repr_uninit);
else
@@ -1842,7 +1842,7 @@ static int eth_ixgbe_pci_remove(struct rte_pci_device *pci_dev)
if (!ethdev)
return 0;
- if (ethdev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR)
+ if (rte_eth_dev_is_repr(ethdev))
return rte_eth_dev_pci_generic_remove(pci_dev,
ixgbe_vf_representor_uninit);
else
@@ -4321,7 +4321,7 @@ int
nfp_flow_ops_get(struct rte_eth_dev *dev,
const struct rte_flow_ops **ops)
{
- if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0) {
+ if (!rte_eth_dev_is_repr(dev)) {
*ops = NULL;
PMD_DRV_LOG(ERR, "Port is not a representor.");
return -EINVAL;
@@ -1066,7 +1066,7 @@ static const struct rte_mtr_ops nfp_mtr_ops = {
int
nfp_net_mtr_ops_get(struct rte_eth_dev *dev, void *arg)
{
- if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0) {
+ if (!rte_eth_dev_is_repr(dev)) {
PMD_DRV_LOG(ERR, "Port is not a representor");
return -EINVAL;
}
@@ -241,7 +241,7 @@ nfp_net_get_hw(const struct rte_eth_dev *dev)
{
struct nfp_net_hw *hw;
- if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) {
+ if (rte_eth_dev_is_repr(dev)) {
struct nfp_flower_representor *repr;
repr = dev->data->dev_private;
hw = repr->app_fw_flower->pf_hw;
@@ -2143,7 +2143,7 @@ nfp_net_firmware_version_get(struct rte_eth_dev *dev,
hw = nfp_net_get_hw(dev);
- if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) {
+ if (rte_eth_dev_is_repr(dev)) {
snprintf(vnic_version, FW_VER_LEN, "%d.%d.%d.%d",
hw->ver.extend, hw->ver.class,
hw->ver.major, hw->ver.minor);
@@ -932,7 +932,7 @@ nfp_net_flow_ops_get(struct rte_eth_dev *dev,
{
struct nfp_net_hw *hw;
- if ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0) {
+ if (rte_eth_dev_is_repr(dev)) {
*ops = NULL;
PMD_DRV_LOG(ERR, "Port is a representor.");
return -EINVAL;
@@ -1813,6 +1813,23 @@ rte_eth_representor_id_get(uint16_t port_id,
int controller, int pf, int representor_port,
uint16_t *repr_id);
+/**
+ * @internal
+ * Check if the ethdev is a representor port.
+ *
+ * @param dev
+ * Pointer to struct rte_eth_dev.
+ *
+ * @return
+ * false the ethdev is not a representor port.
+ * true the ethdev is a representor port.
+ */
+static inline bool
+rte_eth_dev_is_repr(const struct rte_eth_dev *dev)
+{
+ return ((dev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0);
+}
+
/**
* PMD helper function to parse ethdev arguments
*
@@ -69,7 +69,7 @@ eth_representor_cmp(const char *key __rte_unused,
struct rte_eth_devargs eth_da;
uint16_t id = 0, nc, np, nf, i, c, p, f;
- if ((data->dev_flags & RTE_ETH_DEV_REPRESENTOR) == 0)
+ if (!rte_eth_dev_is_repr(edev))
return -1; /* not a representor port */
/* Parse devargs representor values. */
@@ -143,7 +143,7 @@ eth_dev_match(const struct rte_eth_dev *edev,
}
/* if no representor key, default is to not match representor ports */
if (ret != 0)
- if ((edev->data->dev_flags & RTE_ETH_DEV_REPRESENTOR) != 0)
+ if (rte_eth_dev_is_repr(edev))
return -1; /* do not match any representor */
return 0;