net/sfc: support MAC address edits in transfer flows
[dpdk.git] / drivers / net / sfc / sfc.c
index 9c1be10..ed714fe 100644 (file)
@@ -26,6 +26,7 @@
 #include "sfc_tweak.h"
 #include "sfc_sw_stats.h"
 #include "sfc_switch.h"
+#include "sfc_nic_dma.h"
 
 bool
 sfc_repr_supported(const struct sfc_adapter *sa)
@@ -53,10 +54,12 @@ sfc_repr_available(const struct sfc_adapter_shared *sas)
 }
 
 int
-sfc_dma_alloc(const struct sfc_adapter *sa, const char *name, uint16_t id,
-             size_t len, int socket_id, efsys_mem_t *esmp)
+sfc_dma_alloc(struct sfc_adapter *sa, const char *name, uint16_t id,
+             efx_nic_dma_addr_type_t addr_type, size_t len, int socket_id,
+             efsys_mem_t *esmp)
 {
        const struct rte_memzone *mz;
+       int rc;
 
        sfc_log_init(sa, "name=%s id=%u len=%zu socket_id=%d",
                     name, id, len, socket_id);
@@ -69,13 +72,17 @@ sfc_dma_alloc(const struct sfc_adapter *sa, const char *name, uint16_t id,
                        rte_strerror(rte_errno));
                return ENOMEM;
        }
-
-       esmp->esm_addr = mz->iova;
-       if (esmp->esm_addr == RTE_BAD_IOVA) {
+       if (mz->iova == RTE_BAD_IOVA) {
                (void)rte_memzone_free(mz);
                return EFAULT;
        }
 
+       rc = sfc_nic_dma_mz_map(sa, mz, addr_type, &esmp->esm_addr);
+       if (rc != 0) {
+               (void)rte_memzone_free(mz);
+               return rc;
+       }
+
        esmp->esm_mz = mz;
        esmp->esm_base = mz->addr;
 
@@ -457,6 +464,13 @@ sfc_try_start(struct sfc_adapter *sa)
        if (rc != 0)
                goto fail_nic_init;
 
+       sfc_log_init(sa, "reconfigure NIC DMA");
+       rc = efx_nic_dma_reconfigure(sa->nic);
+       if (rc != 0) {
+               sfc_err(sa, "cannot reconfigure NIC DMA: %s", rte_strerror(rc));
+               goto fail_nic_dma_reconfigure;
+       }
+
        encp = efx_nic_cfg_get(sa->nic);
 
        /*
@@ -525,6 +539,7 @@ fail_ev_start:
 
 fail_intr_start:
 fail_tunnel_reconfigure:
+fail_nic_dma_reconfigure:
        efx_nic_fini(sa->nic);
 
 fail_nic_init: