Giter Site home page Giter Site logo

Comments (4)

vincentmli avatar vincentmli commented on June 14, 2024

oh, I think this would address #35 I filed.

from mtcp.

vincentmli avatar vincentmli commented on June 14, 2024

instead of implementing vmxnet3 in igb_uio/igb_uio.c, I found a easier solution, which is to patch SetInterfaceInfo() in mtcp/src/io_module to get MAC address from ports_eth_addr where rte_eth_macaddr_get populated, instead of relying on ioctl to get MAC address from the netdev dpdk* interface, I think this is more portable and solving the pain to support each adapter in igb_uio/igb_uio.c, rough patch as below:

diff --git a/mtcp/src/io_module.c b/mtcp/src/io_module.c
index ad3e01d..83e0893 100644
--- a/mtcp/src/io_module.c
+++ b/mtcp/src/io_module.c
@@ -63,6 +63,22 @@ GetNumQueues()
        return queue_cnt;
 }
 /*----------------------------------------------------------------------------*/
+
+static int GetPortIndex(char *dev_name)
+{
+        char *p = dev_name;
+        long val = -1;
+        while (*p) { // While there are more characters to process...
+                if (isdigit(*p)) { // Upon finding a digit, ...
+                        val = strtol(p, &p, 10); // Read a number, ...
+                } else {
+                        p++;
+                }
+        }
+        return (int)val;
+}
+
+
 int
 SetInterfaceInfo(char* dev_name_list)
 {
@@ -243,9 +259,10 @@ SetInterfaceInfo(char* dev_name_list)
                                        CONFIG.eths[eidx].ip_addr = *(uint32_t *)&sin;
                                }

-                               if (ioctl(sock, SIOCGIFHWADDR, &ifr) == 0 ) {
+                               if(strstr(iter_if->ifa_name, "dpdk") != NULL) {
+                                       ret = GetPortIndex(iter_if->ifa_name);
                                        for (j = 0; j < ETH_ALEN; j ++) {
-                                               CONFIG.eths[eidx].haddr[j] = ifr.ifr_addr.sa_data[j];
+                                               CONFIG.eths[eidx].haddr[j] = ports_eth_addr[ret].addr_bytes[j];
                                        }
                                }

from mtcp.

ajamshed avatar ajamshed commented on June 14, 2024

Thanks. I haven't done any work on vmxnet driver yet. Can you please describe in more detail how this patch can be used to run applications in the VM? As in... what kind of network configuration (mtcp conf file details etc.) would be needed to get mTCP applications operational?

from mtcp.

vincentmli avatar vincentmli commented on June 14, 2024

when running mTCP in ESXi VM environment, the dpdk<#> interface have MAC address of "00:00:00:00:00:00", packet originated from mTCP VM will be dropped by physical switches in our lab enviornment due to the MAC address of "00:00:00:00:00:00". the reason of "00:00:00:00:00:00" is because mTCP DPDK igb_uio/igb_uio.c or igb_uio.h did not implement the case for vmxnet3, but IGB and IXGBE only, I had thought about implement vmxnet3 case in igb_uio/igb_uio.c or igb_uio.h, but I came up above patch to avoid to add vmxnet specific code in following place:

1, in mTCP DPDK igb_uio/igb_uio.c igbuio_pci_probe like code below (switch case for vmxnet3):

        adapter->type = retrieve_dev_specs(id);
        /* recover device-specific mac address */
        switch (adapter->type) {
        case IXGBE:
                hw_i = &adapter->hw._ixgbe_hw;
                hw_i->back = adapter;
                hw_i->hw_addr = ioremap(pci_resource_start(dev, 0),
                                       pci_resource_len(dev, 0));
                if (!hw_i->hw_addr) {
                        err = -EIO;
                        goto fail_ioremap;
                }
                break;
        case IGB:
                hw_e = &adapter->hw._e1000_hw;
                hw_e->back = adapter;
                hw_e->hw_addr = ioremap(pci_resource_start(dev, 0),
                                      pci_resource_len(dev, 0));
                if (!hw_e->hw_addr) {
                        err = -EIO;
                        goto fail_ioremap;
                }
                break;
        }

or in lib/librte_eal/linuxapp/igb_uio/igb_uio.h <<retrieve_dev_addr>> to get MAC address for vmxnet3 for the linux netdev interface dpdk<#> (switch case for vmxnet3)

/**
 * A device specific function that retrieves mac address from each NIC interface
 */
void
retrieve_dev_addr(struct net_device *netdev, struct net_adapter *adapter)
{
        struct ixgbe_hw *hw_i;
        struct e1000_hw *hw_e;
        //struct vmxnet3_hw *hw_x;
        u32 rar_high;
        u32 rar_low;
        u16 i;

        switch (adapter->type) {
        case IXGBE:
                hw_i = &adapter->hw._ixgbe_hw;
                rar_high = IXGBE_READ_REG(hw_i, IXGBE_RAH(0));
                rar_low = IXGBE_READ_REG(hw_i, IXGBE_RAL(0));

                for (i = 0; i < 4; i++)
                        netdev->dev_addr[i] = (u8)(rar_low >> (i*8));

                for (i = 0; i < 2; i++)
                        netdev->dev_addr[i+4] = (u8)(rar_high >> (i*8));
                break;
        case IGB:
                hw_e = &adapter->hw._e1000_hw;
                rar_high = E1000_READ_REG(hw_e, E1000_RAH(0));
                rar_low = E1000_READ_REG(hw_e, E1000_RAL(0));

                for (i = 0; i < E1000_RAL_MAC_ADDR_LEN; i++)
                        netdev->dev_addr[i] = (u8)(rar_low >> (i*8));

                for (i = 0; i < E1000_RAH_MAC_ADDR_LEN; i++)
                        netdev->dev_addr[i+4] = (u8)(rar_high >> (i*8));
                break;
        }

let me know if you are not clear

from mtcp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.