]> git.droids-corp.org - dpdk.git/commitdiff
net/sfc: allow to control the represented entity MAC address
authorIvan Malov <ivan.malov@oktetlabs.ru>
Thu, 26 May 2022 08:45:50 +0000 (11:45 +0300)
committerAndrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Tue, 31 May 2022 16:50:00 +0000 (18:50 +0200)
The MAC address is accessed via the representor ethdev's one.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
drivers/net/sfc/sfc_port.c
drivers/net/sfc/sfc_repr.c
drivers/net/sfc/sfc_repr_proxy.c
drivers/net/sfc/sfc_repr_proxy.h
drivers/net/sfc/sfc_repr_proxy_api.h

index 91139375eaaede12a7ee24597a3b438a96631b1f..5f312ab1ba839fab2cbb69290c93ed44d828f9cb 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include <rte_bitmap.h>
+#include <rte_ether.h>
 
 #include "efx.h"
 
index 9d88d554c1ba261d7bb70ef53fd18e374fbf518f..d0e5385889a28db0e6f64bc0ce5864b007aa9de5 100644 (file)
@@ -853,6 +853,17 @@ sfc_repr_dev_close(struct rte_eth_dev *dev)
        return 0;
 }
 
+static int
+sfc_repr_mac_addr_set(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr)
+{
+       struct sfc_repr_shared *srs = sfc_repr_shared_by_eth_dev(dev);
+       int ret;
+
+       ret = sfc_repr_proxy_repr_entity_mac_addr_set(srs->pf_port_id,
+                                                     srs->repr_id, mac_addr);
+       return -ret;
+}
+
 static int
 sfc_repr_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 {
@@ -889,6 +900,7 @@ static const struct eth_dev_ops sfc_repr_dev_ops = {
        .dev_close                      = sfc_repr_dev_close,
        .dev_infos_get                  = sfc_repr_dev_infos_get,
        .link_update                    = sfc_repr_dev_link_update,
+       .mac_addr_set                   = sfc_repr_mac_addr_set,
        .stats_get                      = sfc_repr_stats_get,
        .rx_queue_setup                 = sfc_repr_rx_queue_setup,
        .rx_queue_release               = sfc_repr_rx_queue_release,
@@ -956,9 +968,9 @@ sfc_repr_eth_dev_init(struct rte_eth_dev *dev, void *init_params)
        }
 
        ret = sfc_repr_proxy_add_port(repr_data->pf_port_id,
-                                     srs->switch_port_id,
-                                     dev->data->port_id,
-                                     &repr_data->mport_sel);
+                                     srs->switch_port_id, dev->data->port_id,
+                                     &repr_data->mport_sel, repr_data->intf,
+                                     repr_data->pf, repr_data->vf);
        if (ret != 0) {
                SFC_GENERIC_LOG(ERR, "%s() failed to add repr proxy port",
                                __func__);
@@ -996,6 +1008,16 @@ sfc_repr_eth_dev_init(struct rte_eth_dev *dev, void *init_params)
                goto fail_mac_addrs;
        }
 
+       rte_eth_random_addr(dev->data->mac_addrs[0].addr_bytes);
+
+       ret = sfc_repr_proxy_repr_entity_mac_addr_set(repr_data->pf_port_id,
+                                                     srs->repr_id,
+                                                     &dev->data->mac_addrs[0]);
+       if (ret != 0) {
+               ret = -ret;
+               goto fail_mac_addr_set;
+       }
+
        dev->rx_pkt_burst = sfc_repr_rx_burst;
        dev->tx_pkt_burst = sfc_repr_tx_burst;
        dev->dev_ops = &sfc_repr_dev_ops;
@@ -1005,6 +1027,7 @@ sfc_repr_eth_dev_init(struct rte_eth_dev *dev, void *init_params)
 
        return 0;
 
+fail_mac_addr_set:
 fail_mac_addrs:
        sfc_repr_unlock(sr);
        free(sr);
index 8660d419a3c52681d384b74517c730e7c8b73eb7..4b958ced61623eabb58829e1c6ebdc0215eb24c9 100644 (file)
@@ -1280,7 +1280,8 @@ sfc_repr_proxy_stop(struct sfc_adapter *sa)
 
 int
 sfc_repr_proxy_add_port(uint16_t pf_port_id, uint16_t repr_id,
-                       uint16_t rte_port_id, const efx_mport_sel_t *mport_sel)
+                       uint16_t rte_port_id, const efx_mport_sel_t *mport_sel,
+                       efx_pcie_interface_t intf, uint16_t pf, uint16_t vf)
 {
        struct sfc_repr_proxy_port *port;
        struct sfc_repr_proxy *rp;
@@ -1319,6 +1320,14 @@ sfc_repr_proxy_add_port(uint16_t pf_port_id, uint16_t repr_id,
        port->rte_port_id = rte_port_id;
        port->repr_id = repr_id;
 
+       rc = efx_mcdi_get_client_handle(sa->nic, intf, pf, vf,
+                                       &port->remote_vnic_mcdi_client_handle);
+       if (rc != 0) {
+               sfc_err(sa, "failed to get the represented VNIC's MCDI handle (repr_id=%u): %s",
+                       repr_id, rte_strerror(rc));
+               goto fail_client_handle;
+       }
+
        if (rp->started) {
                rc = sfc_repr_proxy_mbox_send(&rp->mbox, port,
                                              SFC_REPR_PROXY_MBOX_ADD_PORT);
@@ -1337,6 +1346,7 @@ sfc_repr_proxy_add_port(uint16_t pf_port_id, uint16_t repr_id,
        return 0;
 
 fail_port_add:
+fail_client_handle:
 fail_mport_id:
        rte_free(port);
 fail_alloc_port:
@@ -1664,3 +1674,36 @@ sfc_repr_proxy_stop_repr(uint16_t pf_port_id, uint16_t repr_id)
 
        return 0;
 }
+
+int
+sfc_repr_proxy_repr_entity_mac_addr_set(uint16_t pf_port_id, uint16_t repr_id,
+                                       const struct rte_ether_addr *mac_addr)
+{
+       struct sfc_repr_proxy_port *port;
+       struct sfc_repr_proxy *rp;
+       struct sfc_adapter *sa;
+       int rc;
+
+       sa = sfc_get_adapter_by_pf_port_id(pf_port_id);
+       rp = sfc_repr_proxy_by_adapter(sa);
+
+       port = sfc_repr_proxy_find_port(rp, repr_id);
+       if (port == NULL) {
+               sfc_err(sa, "%s() failed: no such port (repr_id=%u)",
+                       __func__, repr_id);
+               sfc_put_adapter(sa);
+               return ENOENT;
+       }
+
+       rc = efx_mcdi_client_mac_addr_set(sa->nic,
+                                         port->remote_vnic_mcdi_client_handle,
+                                         mac_addr->addr_bytes);
+       if (rc != 0) {
+               sfc_err(sa, "%s() failed: cannot set MAC address (repr_id=%u): %s",
+                       __func__, repr_id, rte_strerror(rc));
+       }
+
+       sfc_put_adapter(sa);
+
+       return rc;
+}
index b49b1a2a96fea911b63e79bb2bab0a0383cd61d7..260e2cab30e586067435d6b1d1e4389cbde3c4e6 100644 (file)
@@ -64,6 +64,7 @@ struct sfc_repr_proxy_port {
        uint16_t                                repr_id;
        uint16_t                                rte_port_id;
        efx_mport_id_t                          egress_mport;
+       uint32_t                                remote_vnic_mcdi_client_handle;
        struct sfc_repr_proxy_rxq               rxq[SFC_REPR_RXQ_MAX];
        struct sfc_repr_proxy_txq               txq[SFC_REPR_TXQ_MAX];
        struct sfc_mae_rule                     *mae_rule;
index 95b065801d42dfbdfc7bb4b31328ec4696a7d3ea..1d38ab2451c470a31fc6738fc0d4d14245ebac66 100644 (file)
@@ -23,7 +23,9 @@ extern "C" {
 
 int sfc_repr_proxy_add_port(uint16_t pf_port_id, uint16_t repr_id,
                            uint16_t rte_port_id,
-                           const efx_mport_sel_t *mport_set);
+                           const efx_mport_sel_t *mport_sel,
+                           efx_pcie_interface_t intf, uint16_t pf,
+                           uint16_t vf);
 int sfc_repr_proxy_del_port(uint16_t pf_port_id, uint16_t repr_id);
 
 int sfc_repr_proxy_add_rxq(uint16_t pf_port_id, uint16_t repr_id,
@@ -41,6 +43,9 @@ void sfc_repr_proxy_del_txq(uint16_t pf_port_id, uint16_t repr_id,
 int sfc_repr_proxy_start_repr(uint16_t pf_port_id, uint16_t repr_id);
 int sfc_repr_proxy_stop_repr(uint16_t pf_port_id, uint16_t repr_id);
 
+int sfc_repr_proxy_repr_entity_mac_addr_set(uint16_t pf_port_id,
+               uint16_t repr_id, const struct rte_ether_addr *mac_addr);
+
 #ifdef __cplusplus
 }
 #endif