net/mlx5: move Linux-specific functions
[dpdk.git] / drivers / net / sfc / base / ef10_evb.c
index aaa97f6..aeeaa51 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
- * Copyright (c) 2018-2019 Solarflare Communications Inc.
- * All rights reserved.
+ * Copyright(c) 2019-2020 Xilinx, Inc.
+ * Copyright(c) 2018-2019 Solarflare Communications Inc.
  */
 
 #include "efx.h"
@@ -9,15 +9,13 @@
 
 #if EFSYS_OPT_EVB
 
-#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
+#if EFX_OPTS_EF10()
 
        __checkReturn   efx_rc_t
 ef10_evb_init(
        __in            efx_nic_t *enp)
 {
-       EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-               enp->en_family == EFX_FAMILY_MEDFORD ||
-               enp->en_family == EFX_FAMILY_MEDFORD2);
+       EFSYS_ASSERT(EFX_FAMILY_IS_EF10(enp));
 
        return (0);
 }
@@ -26,12 +24,10 @@ ef10_evb_init(
 ef10_evb_fini(
        __in            efx_nic_t *enp)
 {
-       EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
-               enp->en_family == EFX_FAMILY_MEDFORD ||
-               enp->en_family == EFX_FAMILY_MEDFORD2);
+       EFSYS_ASSERT(EFX_FAMILY_IS_EF10(enp));
 }
 
-       __checkReturn   efx_rc_t
+static __checkReturn   efx_rc_t
 efx_mcdi_vswitch_alloc(
        __in            efx_nic_t *enp,
        __in            efx_vport_id_t vport_id,
@@ -98,7 +94,7 @@ fail1:
        return (rc);
 }
 
-       __checkReturn   efx_rc_t
+static __checkReturn   efx_rc_t
 efx_mcdi_vswitch_free(
        __in            efx_nic_t *enp)
 {
@@ -129,7 +125,7 @@ fail1:
        return (rc);
 }
 
-       __checkReturn   efx_rc_t
+static __checkReturn   efx_rc_t
 efx_mcdi_vport_alloc(
        __in            efx_nic_t *enp,
        __in            efx_vport_type_t vport_type,
@@ -192,7 +188,7 @@ fail1:
        return (rc);
 }
 
-       __checkReturn   efx_rc_t
+static __checkReturn   efx_rc_t
 efx_mcdi_vport_free(
        __in            efx_nic_t *enp,
        __in            efx_vport_id_t vport_id)
@@ -223,7 +219,7 @@ fail1:
        return (rc);
 }
 
-       __checkReturn                   efx_rc_t
+static __checkReturn                   efx_rc_t
 efx_mcdi_vport_mac_addr_add(
        __in                            efx_nic_t *enp,
        __in                            efx_vport_id_t vport_id,
@@ -258,7 +254,7 @@ fail1:
        return (rc);
 }
 
-       __checkReturn                   efx_rc_t
+static __checkReturn                   efx_rc_t
 efx_mcdi_vport_mac_addr_del(
        __in                            efx_nic_t *enp,
        __in                            efx_vport_id_t vport_id,
@@ -293,7 +289,7 @@ fail1:
        return (rc);
 }
 
-       __checkReturn   efx_rc_t
+static __checkReturn   efx_rc_t
 efx_mcdi_port_assign(
        __in            efx_nic_t *enp,
        __in            efx_vport_id_t vport_id,
@@ -330,6 +326,74 @@ fail1:
        return (rc);
 }
 
+static __checkReturn                           efx_rc_t
+efx_mcdi_vport_reconfigure(
+       __in                                    efx_nic_t *enp,
+       __in                                    efx_vport_id_t vport_id,
+       __in_opt                                uint16_t *vidp,
+       __in_bcount_opt(EFX_MAC_ADDR_LEN)       uint8_t *addrp,
+       __out_opt                               boolean_t *fn_resetp)
+{
+       EFX_MCDI_DECLARE_BUF(payload, MC_CMD_VPORT_RECONFIGURE_IN_LEN,
+               MC_CMD_VPORT_RECONFIGURE_OUT_LEN);
+       efx_mcdi_req_t req;
+       efx_rc_t rc;
+       uint32_t reset_flag = 0;
+
+       req.emr_cmd = MC_CMD_VPORT_RECONFIGURE;
+       req.emr_in_buf = payload;
+       req.emr_in_length = MC_CMD_VPORT_RECONFIGURE_IN_LEN;
+       req.emr_out_buf = payload;
+       req.emr_out_length = MC_CMD_VPORT_RECONFIGURE_OUT_LEN;
+
+       MCDI_IN_SET_DWORD(req, VPORT_RECONFIGURE_IN_VPORT_ID, vport_id);
+
+       if (vidp != NULL) {
+               MCDI_IN_POPULATE_DWORD_1(req, VPORT_RECONFIGURE_IN_FLAGS,
+                       VPORT_RECONFIGURE_IN_REPLACE_VLAN_TAGS, 1);
+               if (*vidp != EFX_FILTER_VID_UNSPEC) {
+                       MCDI_IN_SET_DWORD(req,
+                               VPORT_RECONFIGURE_IN_NUM_VLAN_TAGS, 1);
+                       MCDI_IN_POPULATE_DWORD_1(req,
+                               VPORT_RECONFIGURE_IN_VLAN_TAGS,
+                               VPORT_RECONFIGURE_IN_VLAN_TAG_0, *vidp);
+               }
+       }
+
+       if ((addrp != NULL) && (efx_is_zero_eth_addr(addrp) == B_FALSE)) {
+               MCDI_IN_POPULATE_DWORD_1(req, VPORT_RECONFIGURE_IN_FLAGS,
+                        VPORT_RECONFIGURE_IN_REPLACE_MACADDRS, 1);
+               MCDI_IN_SET_DWORD(req, VPORT_RECONFIGURE_IN_NUM_MACADDRS, 1);
+               EFX_MAC_ADDR_COPY(MCDI_IN2(req, uint8_t,
+                                       VPORT_RECONFIGURE_IN_MACADDRS), addrp);
+       }
+
+       efx_mcdi_execute(enp, &req);
+       if (req.emr_rc != 0) {
+               rc = req.emr_rc;
+               goto fail1;
+       }
+
+       if (req.emr_out_length_used < MC_CMD_VPORT_RECONFIGURE_OUT_LEN) {
+               rc = EMSGSIZE;
+               goto fail2;
+       }
+
+       reset_flag = MCDI_OUT_DWORD_FIELD(req, VPORT_RECONFIGURE_OUT_FLAGS,
+                                           VPORT_RECONFIGURE_OUT_RESET_DONE);
+
+       if (fn_resetp != NULL)
+               *fn_resetp = (reset_flag != 0);
+
+       return (0);
+
+fail2:
+       EFSYS_PROBE(fail2);
+fail1:
+       EFSYS_PROBE1(fail1, efx_rc_t, rc);
+       return (rc);
+}
+
        __checkReturn   efx_rc_t
 ef10_evb_vswitch_alloc(
        __in            efx_nic_t *enp,
@@ -453,5 +517,33 @@ ef10_evb_vport_assign(
        return (efx_mcdi_port_assign(enp, vport_id, vf_index));
 }
 
-#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
+       __checkReturn                           efx_rc_t
+ef10_evb_vport_reconfigure(
+       __in                                    efx_nic_t *enp,
+       __in                                    efx_vswitch_id_t vswitch_id,
+       __in                                    efx_vport_id_t vport_id,
+       __in_opt                                uint16_t *vidp,
+       __in_bcount_opt(EFX_MAC_ADDR_LEN)       uint8_t *addrp,
+       __out_opt                               boolean_t *fn_resetp)
+{
+       _NOTE(ARGUNUSED(vswitch_id))
+
+       return (efx_mcdi_vport_reconfigure(enp, vport_id, vidp,
+                       addrp, fn_resetp));
+}
+
+       __checkReturn   efx_rc_t
+ef10_evb_vport_stats(
+       __in            efx_nic_t *enp,
+       __in            efx_vswitch_id_t vswitch_id,
+       __in            efx_vport_id_t vport_id,
+       __in            efsys_mem_t *esmp)
+{
+       _NOTE(ARGUNUSED(vswitch_id))
+
+       return (efx_mcdi_mac_stats(enp, vport_id, esmp,
+                       EFX_STATS_UPLOAD, 0));
+}
+
+#endif /* EFX_OPTS_EF10() */
 #endif /* EFSYS_OPT_EVB */