From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 24135A0555; Thu, 26 May 2022 10:46:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C26B7427F7; Thu, 26 May 2022 10:45:55 +0200 (CEST) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 84D4840DF7 for ; Thu, 26 May 2022 10:45:53 +0200 (CEST) Received: from bree.oktetlabs.ru (bree.oktetlabs.ru [192.168.34.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by shelob.oktetlabs.ru (Postfix) with ESMTPS id ED14694; Thu, 26 May 2022 11:45:52 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru ED14694 Authentication-Results: shelob.oktetlabs.ru/ED14694; dkim=none; dkim-atps=neutral From: Ivan Malov To: dev@dpdk.org Cc: Andrew Rybchenko , Andy Moreton Subject: [PATCH 3/3] net/sfc: allow to control the represented entity MAC address Date: Thu, 26 May 2022 11:45:50 +0300 Message-Id: <20220526084550.243121-3-ivan.malov@oktetlabs.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220526084550.243121-1-ivan.malov@oktetlabs.ru> References: <20220526084550.243121-1-ivan.malov@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The MAC address is accessed via the representor ethdev's one. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/net/sfc/sfc_port.c | 1 + drivers/net/sfc/sfc_repr.c | 29 ++++++++++++++++-- drivers/net/sfc/sfc_repr_proxy.c | 45 +++++++++++++++++++++++++++- drivers/net/sfc/sfc_repr_proxy.h | 1 + drivers/net/sfc/sfc_repr_proxy_api.h | 7 ++++- 5 files changed, 78 insertions(+), 5 deletions(-) diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c index 91139375ea..5f312ab1ba 100644 --- a/drivers/net/sfc/sfc_port.c +++ b/drivers/net/sfc/sfc_port.c @@ -8,6 +8,7 @@ */ #include +#include #include "efx.h" diff --git a/drivers/net/sfc/sfc_repr.c b/drivers/net/sfc/sfc_repr.c index 9d88d554c1..d0e5385889 100644 --- a/drivers/net/sfc/sfc_repr.c +++ b/drivers/net/sfc/sfc_repr.c @@ -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); diff --git a/drivers/net/sfc/sfc_repr_proxy.c b/drivers/net/sfc/sfc_repr_proxy.c index 8660d419a3..4b958ced61 100644 --- a/drivers/net/sfc/sfc_repr_proxy.c +++ b/drivers/net/sfc/sfc_repr_proxy.c @@ -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; +} diff --git a/drivers/net/sfc/sfc_repr_proxy.h b/drivers/net/sfc/sfc_repr_proxy.h index b49b1a2a96..260e2cab30 100644 --- a/drivers/net/sfc/sfc_repr_proxy.h +++ b/drivers/net/sfc/sfc_repr_proxy.h @@ -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; diff --git a/drivers/net/sfc/sfc_repr_proxy_api.h b/drivers/net/sfc/sfc_repr_proxy_api.h index 95b065801d..1d38ab2451 100644 --- a/drivers/net/sfc/sfc_repr_proxy_api.h +++ b/drivers/net/sfc/sfc_repr_proxy_api.h @@ -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 -- 2.30.2