Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to implement the "setting mac address " for VF which is a qdma device using QDMA-DPDK testpmd application #296

Open
vijayaKesavan19 opened this issue Oct 3, 2024 · 0 comments

Comments

@vijayaKesavan19
Copy link

vijayaKesavan19 commented Oct 3, 2024

Hi team,

I am trying to do port representor testing on QDMA-DPDK using the openNIC design project.
github link for the openNIC design project

For that I need to test changing the mac address of the PF and VF (from the PF).

For setting MAC of PF I use this command testpmd> mac_addr set <port id> <XX:XX:XX:XX:XX:XX>

I was able to do that by writing a function which is given below

int qdma_set_mac_address(struct rte_eth_dev *dev, struct rte_ether_addr *addr)
{
        int i ;
        uint64_t mac_addr = (uint64_t)(uintptr_t)&addr;
        if (!rte_is_valid_assigned_ether_addr(addr))
               return -EADDRNOTAVAIL;
        for (i = 0; i < RTE_ETHER_ADDR_LEN; i++)
                dev->data->mac_addrs[0].addr_bytes[RTE_ETHER_ADDR_LEN -1 -i] =
                                                (uint8_t)((mac_addr >> (BITS_IN_BYTE * i)) & 0xFF);
        return 0;
}

File : drivers/net/qdma/qdma_devops.c

For setting MAC of VF I use this command testpmd> set vf mac addr <port id> <vf id> <XX:XX:XX:XX:XX:XX>
I hope the below funciton is called.


static void  (
        void *parsed_result,
        __rte_unused struct cmdline *cl,
        __rte_unused void *data)
{
        struct cmd_set_vf_mac_addr_result *res = parsed_result;
        int ret = -ENOTSUP;

        if (port_id_is_invalid(res->port_id, ENABLED_WARN))
                return;

#ifdef RTE_NET_IXGBE
        if (ret == -ENOTSUP)
                ret = rte_pmd_ixgbe_set_vf_mac_addr(res->port_id, res->vf_id,
                                &res->mac_addr);
#endif
#ifdef RTE_NET_I40E
        if (ret == -ENOTSUP)
                ret = rte_pmd_i40e_set_vf_mac_addr(res->port_id, res->vf_id,
                                &res->mac_addr);
#endif
#ifdef RTE_NET_BNXT
        if (ret == -ENOTSUP)
                ret = rte_pmd_bnxt_set_vf_mac_addr(res->port_id, res->vf_id,
                                &res->mac_addr);
#endif
     
        switch (ret) {
        case 0:
                break;
        case -EINVAL:
                printf("invalid vf_id %d or mac_addr\n", res->vf_id);
                break;
        case -ENODEV:
                printf("invalid port_id %d\n", res->port_id);
                break;
        case -ENOTSUP:
                printf("function not implemented\n");
                break;
        default:
                printf("programming error: (%s)\n", strerror(-ret));
        }
}

File : dpdk-20.11/app/test-pmd/cmdline.c Line: 11427

Which is supported only when the pf and vf is ixgbe, i40e or bnxt device. But what I am using is qdma device (i.e: device name of the VF is "qdma_vf" ).

The below is the one of the driver function for setting mac address

int
rte_pmd_ixgbe_set_vf_mac_addr(uint16_t port, uint16_t vf,
                              struct rte_ether_addr *mac_addr)
{
        struct ixgbe_hw *hw;
        struct ixgbe_vf_info *vfinfo;
        int rar_entry;
        uint8_t *new_mac = (uint8_t *)(mac_addr);
        struct rte_eth_dev *dev;
        struct rte_pci_device *pci_dev;

        RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);

        dev = &rte_eth_devices[port];
        pci_dev = RTE_ETH_DEV_TO_PCI(dev);

        if (!is_ixgbe_supported(dev))
                return -ENOTSUP;

        if (vf >= pci_dev->max_vfs)
                return -EINVAL;

        **hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
        vfinfo = *(IXGBE_DEV_PRIVATE_TO_P_VFDATA(dev->data->dev_private));**
        rar_entry = hw->mac.num_rar_entries - (vf + 1);

        if (rte_is_valid_assigned_ether_addr(
                        (struct rte_ether_addr *)new_mac)) {
                rte_memcpy(vfinfo[vf].vf_mac_addresses, new_mac,
                           RTE_ETHER_ADDR_LEN);
                return hw->mac.ops.set_rar(hw, rar_entry, new_mac, vf,
                                           IXGBE_RAH_AV);
        }
        return -EINVAL;
}

File : drivers/net/ixgbe/rte_pmd_ixgbe.c Line: 1174

As you can see the dev->data->private member was casted by the ixgbe driver preference to fetch the VF's info.
Structure of ixgbe_vf_info

struct ixgbe_vf_info {
        uint8_t vf_mac_addresses[RTE_ETHER_ADDR_LEN];
        uint16_t vf_mc_hashes[IXGBE_MAX_VF_MC_ENTRIES];
        uint16_t num_vf_mc_hashes;
        uint16_t default_vf_vlan_id;
        uint16_t vlans_enabled;
        bool clear_to_send;
        uint16_t tx_rate[IXGBE_MAX_QUEUE_NUM_PER_VF];
        uint16_t vlan_count;
        uint8_t spoofchk_enabled;
        uint8_t api_version;
        uint16_t switch_domain_id;
        uint16_t xcast_mode;
        uint16_t mac_count;
};

In qdma driver I can only fetch the function id of the VF on the vfinfo.

struct qdma_vf_info {
        uint16_t        func_id;
};

Can you tell me how to access the mac address and received packets of the qdma_vf device(VF) through the physical function(PF) on QDMA-DPDK testpmd application.

This issue is causing a major disruption in our production environment. Could you please consider labeling it as high priority?

Thank you in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant