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>
*/
#include <rte_bitmap.h>
+#include <rte_ether.h>
#include "efx.h"
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)
{
.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,
}
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__);
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;
return 0;
+fail_mac_addr_set:
fail_mac_addrs:
sfc_repr_unlock(sr);
free(sr);
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;
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);
return 0;
fail_port_add:
+fail_client_handle:
fail_mport_id:
rte_free(port);
fail_alloc_port:
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;
+}
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;
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,
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