Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Dec 2015 10:31:03 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r292196 - in stable/10/sys: dev/mlx5 dev/mlx5/mlx5_core modules/mlx5
Message-ID:  <201512141031.tBEAV3al036539@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Mon Dec 14 10:31:03 2015
New Revision: 292196
URL: https://svnweb.freebsd.org/changeset/base/292196

Log:
  MFC r291939:
  Update the mlx5 shared driver code to the latest version, which
  include the following list of changes:
  
  - Added eswitch ACL table management
    Introduce API for managing ACL table.
    This API include the following features:
    1) vlan filter - for VST/VGT+ support.
    2) spoofcheck.
    3) robust functionality to allow/drop general untagged/tagged traffic.
    4) support for both ingress and egress ACL types.
  
  - Added loopback filter to the vacl table.
  
  - Added multicast list set in the vPort context
  
  - Added promiscuous mode set in the vPort context
  
  - Set the vlan list in vPort context
    1) Check caps if VLAN list is not longer than FW supports
    2) Set MODIFY_NIC_VPORT_CONTEXT command
  
  - Changed MLX5_EEPROM_MAX_BYTES from 48 to 32 so that a single EEPROM
    reading cannot cross the 128-byte boundary. Previously reading the
    MCIA register was done in batches of 48 bytes. The third reading
    would then by-pass the 127th byte, which means that part of the low
    page and part of the high page would be read at the same time, which
    created a bug:
      1st: 0-47 bytes
      2nd: 48-95 bytes
      3rd: 96-143 bytes
  
  Sponsored by:	Mellanox Technologies
  Differential Revision:	https://reviews.freebsd.org/D4411

Added:
  stable/10/sys/dev/mlx5/eswitch_vacl.h
     - copied unchanged from r291939, head/sys/dev/mlx5/eswitch_vacl.h
  stable/10/sys/dev/mlx5/mlx5_core/mlx5_eswitch_vacl.c
     - copied, changed from r291939, head/sys/dev/mlx5/mlx5_core/mlx5_eswitch_vacl.c
Modified:
  stable/10/sys/dev/mlx5/device.h
  stable/10/sys/dev/mlx5/driver.h
  stable/10/sys/dev/mlx5/mlx5_core/mlx5_eq.c
  stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c
  stable/10/sys/dev/mlx5/vport.h
  stable/10/sys/modules/mlx5/Makefile
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/mlx5/device.h
==============================================================================
--- stable/10/sys/dev/mlx5/device.h	Mon Dec 14 10:18:04 2015	(r292195)
+++ stable/10/sys/dev/mlx5/device.h	Mon Dec 14 10:31:03 2015	(r292196)
@@ -1023,6 +1023,25 @@ enum {
 	MLX5_MODIFY_ESW_VPORT_CONTEXT_FIELD_SELECT_CVLAN_INSERT = 1 << 3
 };
 
+enum {
+	MLX5_UC_ADDR_CHANGE = (1 << 0),
+	MLX5_MC_ADDR_CHANGE = (1 << 1),
+	MLX5_VLAN_CHANGE    = (1 << 2),
+	MLX5_PROMISC_CHANGE = (1 << 3),
+	MLX5_MTU_CHANGE     = (1 << 4),
+};
+
+enum mlx5_list_type {
+	MLX5_NIC_VPORT_LIST_TYPE_UC   = 0x0,
+	MLX5_NIC_VPORT_LIST_TYPE_MC   = 0x1,
+	MLX5_NIC_VPORT_LIST_TYPE_VLAN = 0x2,
+};
+
+enum {
+	MLX5_ESW_VPORT_ADMIN_STATE_DOWN  = 0x0,
+	MLX5_ESW_VPORT_ADMIN_STATE_UP    = 0x1,
+	MLX5_ESW_VPORT_ADMIN_STATE_AUTO  = 0x2,
+};
 /* MLX5 DEV CAPs */
 
 /* TODO: EAT.ME */
@@ -1087,6 +1106,22 @@ enum mlx5_cap_type {
 	MLX5_GET(flow_table_eswitch_cap, \
 		 mdev->hca_caps_max[MLX5_CAP_ESWITCH_FLOW_TABLE], cap)
 
+#define MLX5_CAP_ESW_FLOWTABLE_EGRESS_ACL(mdev, cap) \
+	MLX5_CAP_ESW_FLOWTABLE(dev, \
+			       flow_table_properties_esw_acl_egress.cap)
+
+#define MLX5_CAP_ESW_FLOWTABLE_EGRESS_ACL_MAX(mdev, cap) \
+	MLX5_CAP_ESW_FLOWTABLE_MAX(dev, \
+				   flow_table_properties_esw_acl_egress.cap)
+
+#define MLX5_CAP_ESW_FLOWTABLE_INGRESS_ACL(mdev, cap) \
+	MLX5_CAP_ESW_FLOWTABLE(dev, \
+			       flow_table_properties_esw_acl_ingress.cap)
+
+#define MLX5_CAP_ESW_FLOWTABLE_INGRESS_ACL_MAX(mdev, cap) \
+	MLX5_CAP_ESW_FLOWTABLE_MAX(dev, \
+				   flow_table_properties_esw_acl_ingress.cap)
+
 #define MLX5_CAP_ESW(mdev, cap) \
 	MLX5_GET(e_switch_cap, \
 		 mdev->hca_caps_cur[MLX5_CAP_ESWITCH], cap)

Modified: stable/10/sys/dev/mlx5/driver.h
==============================================================================
--- stable/10/sys/dev/mlx5/driver.h	Mon Dec 14 10:18:04 2015	(r292195)
+++ stable/10/sys/dev/mlx5/driver.h	Mon Dec 14 10:31:03 2015	(r292196)
@@ -934,7 +934,7 @@ struct mlx5_profile {
 };
 
 
-#define MLX5_EEPROM_MAX_BYTES			48
+#define MLX5_EEPROM_MAX_BYTES			32
 #define MLX5_EEPROM_IDENTIFIER_BYTE_MASK	0x000000ff
 #define MLX5_EEPROM_REVISION_ID_BYTE_MASK	0x0000ff00
 #define MLX5_EEPROM_PAGE_3_VALID_BIT_MASK	0x00040000

Copied: stable/10/sys/dev/mlx5/eswitch_vacl.h (from r291939, head/sys/dev/mlx5/eswitch_vacl.h)
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ stable/10/sys/dev/mlx5/eswitch_vacl.h	Mon Dec 14 10:31:03 2015	(r292196, copy of r291939, head/sys/dev/mlx5/eswitch_vacl.h)
@@ -0,0 +1,46 @@
+/*-
+ * Copyright (c) 2013-2015, Mellanox Technologies, Ltd.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ */
+
+#ifndef MLX5_ESWITCH_VACL_TABLE_H
+#define MLX5_ESWITCH_VACL_TABLE_H
+
+#include <dev/mlx5/driver.h>
+
+void *mlx5_vacl_table_create(struct mlx5_core_dev *dev,
+			     u16 vport, bool is_egress);
+void mlx5_vacl_table_cleanup(void *acl_t);
+int mlx5_vacl_table_add_vlan(void *acl_t, u16 vlan);
+void mlx5_vacl_table_del_vlan(void *acl_t, u16 vlan);
+int mlx5_vacl_table_enable_vlan_filter(void *acl_t);
+void mlx5_vacl_table_disable_vlan_filter(void *acl_t);
+int mlx5_vacl_table_drop_untagged(void *acl_t);
+int mlx5_vacl_table_allow_untagged(void *acl_t);
+int mlx5_vacl_table_drop_unknown_vlan(void *acl_t);
+int mlx5_vacl_table_allow_unknown_vlan(void *acl_t);
+int mlx5_vacl_table_set_spoofchk(void *acl_t, bool spoofchk, u8 *vport_mac);
+
+#endif /* MLX5_ESWITCH_VACL_TABLE_H */

Modified: stable/10/sys/dev/mlx5/mlx5_core/mlx5_eq.c
==============================================================================
--- stable/10/sys/dev/mlx5/mlx5_core/mlx5_eq.c	Mon Dec 14 10:18:04 2015	(r292195)
+++ stable/10/sys/dev/mlx5/mlx5_core/mlx5_eq.c	Mon Dec 14 10:31:03 2015	(r292196)
@@ -64,7 +64,6 @@ enum {
 			       (1ull << MLX5_EVENT_TYPE_WQ_INVAL_REQ_ERROR) | \
 			       (1ull << MLX5_EVENT_TYPE_WQ_ACCESS_ERROR)    | \
 			       (1ull << MLX5_EVENT_TYPE_PORT_CHANGE)	    | \
-			       (1ull << MLX5_EVENT_TYPE_NIC_VPORT_CHANGE)   | \
 			       (1ull << MLX5_EVENT_TYPE_SRQ_CATAS_ERROR)    | \
 			       (1ull << MLX5_EVENT_TYPE_SRQ_LAST_WQE)	    | \
 			       (1ull << MLX5_EVENT_TYPE_SRQ_RQ_LIMIT))
@@ -475,6 +474,10 @@ int mlx5_start_eqs(struct mlx5_core_dev 
 		async_event_mask |= (1ull <<
 				     MLX5_EVENT_TYPE_CODING_PORT_MODULE_EVENT);
 
+	if (MLX5_CAP_GEN(dev, nic_vport_change_event))
+		async_event_mask |= (1ull <<
+				     MLX5_EVENT_TYPE_NIC_VPORT_CHANGE);
+
 	err = mlx5_create_map_eq(dev, &table->cmd_eq, MLX5_EQ_VEC_CMD,
 				 MLX5_NUM_CMD_EQE, 1ull << MLX5_EVENT_TYPE_CMD,
 				 "mlx5_cmd_eq", &dev->priv.uuari.uars[0]);

Copied and modified: stable/10/sys/dev/mlx5/mlx5_core/mlx5_eswitch_vacl.c (from r291939, head/sys/dev/mlx5/mlx5_core/mlx5_eswitch_vacl.c)
==============================================================================
--- head/sys/dev/mlx5/mlx5_core/mlx5_eswitch_vacl.c	Mon Dec  7 13:16:48 2015	(r291939, copy source)
+++ stable/10/sys/dev/mlx5/mlx5_core/mlx5_eswitch_vacl.c	Mon Dec 14 10:31:03 2015	(r292196)
@@ -25,6 +25,7 @@
  * $FreeBSD$
  */
 
+#include <linux/if_ether.h>
 #include <linux/etherdevice.h>
 #include <dev/mlx5/driver.h>
 #include <dev/mlx5/flow_table.h>

Modified: stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c
==============================================================================
--- stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c	Mon Dec 14 10:18:04 2015	(r292195)
+++ stable/10/sys/dev/mlx5/mlx5_core/mlx5_vport.c	Mon Dec 14 10:31:03 2015	(r292196)
@@ -328,7 +328,8 @@ int mlx5_set_nic_vport_current_mac(struc
 	MLX5_SET(modify_nic_vport_context_in, in,
 		 field_select.addresses_list, 1);
 	MLX5_SET(modify_nic_vport_context_in, in,
-		 nic_vport_context.allowed_list_type, 0);
+		 nic_vport_context.allowed_list_type,
+		 MLX5_NIC_VPORT_LIST_TYPE_UC);
 	MLX5_SET(modify_nic_vport_context_in, in,
 		 nic_vport_context.allowed_list_size, 1);
 
@@ -345,6 +346,131 @@ int mlx5_set_nic_vport_current_mac(struc
 	return err;
 }
 EXPORT_SYMBOL_GPL(mlx5_set_nic_vport_current_mac);
+
+int mlx5_set_nic_vport_vlan_list(struct mlx5_core_dev *dev, u32 vport,
+				 u16 *vlan_list, int list_len)
+{
+	void *in, *ctx;
+	int i, err;
+	int  inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in)
+		+ MLX5_ST_SZ_BYTES(vlan_layout) * (int)list_len;
+
+	int max_list_size = 1 << MLX5_CAP_GEN_MAX(dev, log_max_vlan_list);
+
+	if (list_len > max_list_size) {
+		mlx5_core_warn(dev, "Requested list size (%d) > (%d) max_list_size\n",
+			       list_len, max_list_size);
+		return -ENOSPC;
+	}
+
+	in = mlx5_vzalloc(inlen);
+	if (!in) {
+		mlx5_core_warn(dev, "failed to allocate inbox\n");
+		return -ENOMEM;
+	}
+
+	MLX5_SET(modify_nic_vport_context_in, in, vport_number, vport);
+	if (vport)
+		MLX5_SET(modify_nic_vport_context_in, in,
+			 other_vport, 1);
+	MLX5_SET(modify_nic_vport_context_in, in,
+		 field_select.addresses_list, 1);
+
+	ctx = MLX5_ADDR_OF(modify_nic_vport_context_in, in, nic_vport_context);
+
+	MLX5_SET(nic_vport_context, ctx, allowed_list_type,
+		 MLX5_NIC_VPORT_LIST_TYPE_VLAN);
+	MLX5_SET(nic_vport_context, ctx, allowed_list_size, list_len);
+
+	for (i = 0; i < list_len; i++) {
+		u8 *vlan_lout = MLX5_ADDR_OF(nic_vport_context, ctx,
+					 current_uc_mac_address[i]);
+		MLX5_SET(vlan_layout, vlan_lout, vlan, vlan_list[i]);
+	}
+
+	err = mlx5_modify_nic_vport_context(dev, in, inlen);
+
+	kvfree(in);
+	return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_set_nic_vport_vlan_list);
+
+int mlx5_set_nic_vport_mc_list(struct mlx5_core_dev *mdev, int vport,
+			       u64 *addr_list, size_t addr_list_len)
+{
+	void *in, *ctx;
+	int  inlen = MLX5_ST_SZ_BYTES(modify_nic_vport_context_in)
+		  + MLX5_ST_SZ_BYTES(mac_address_layout) * (int)addr_list_len;
+	int err;
+	size_t i;
+	int max_list_sz = 1 << MLX5_CAP_GEN_MAX(mdev, log_max_current_mc_list);
+
+	if ((int)addr_list_len > max_list_sz) {
+		mlx5_core_warn(mdev, "Requested list size (%d) > (%d) max_list_size\n",
+			       (int)addr_list_len, max_list_sz);
+		return -ENOSPC;
+	}
+
+	in = mlx5_vzalloc(inlen);
+	if (!in) {
+		mlx5_core_warn(mdev, "failed to allocate inbox\n");
+		return -ENOMEM;
+	}
+
+	MLX5_SET(modify_nic_vport_context_in, in, vport_number, vport);
+	if (vport)
+		MLX5_SET(modify_nic_vport_context_in, in,
+			 other_vport, 1);
+	MLX5_SET(modify_nic_vport_context_in, in,
+		 field_select.addresses_list, 1);
+
+	ctx = MLX5_ADDR_OF(modify_nic_vport_context_in, in, nic_vport_context);
+
+	MLX5_SET(nic_vport_context, ctx, allowed_list_type,
+		 MLX5_NIC_VPORT_LIST_TYPE_MC);
+	MLX5_SET(nic_vport_context, ctx, allowed_list_size, addr_list_len);
+
+	for (i = 0; i < addr_list_len; i++) {
+		u8 *mac_lout = (u8 *)MLX5_ADDR_OF(nic_vport_context, ctx,
+						  current_uc_mac_address[i]);
+		u8 *mac_ptr = (u8 *)MLX5_ADDR_OF(mac_address_layout, mac_lout,
+						 mac_addr_47_32);
+		ether_addr_copy(mac_ptr, (u8 *)&addr_list[i]);
+	}
+
+	err = mlx5_modify_nic_vport_context(mdev, in, inlen);
+
+	kvfree(in);
+
+	return err;
+}
+EXPORT_SYMBOL_GPL(mlx5_set_nic_vport_mc_list);
+
+int mlx5_set_nic_vport_promisc(struct mlx5_core_dev *mdev, int vport,
+			       bool promisc_mc, bool promisc_uc,
+			       bool promisc_all)
+{
+	u8  in[MLX5_ST_SZ_BYTES(modify_nic_vport_context_in)];
+	u8 *ctx = MLX5_ADDR_OF(modify_nic_vport_context_in, in,
+			       nic_vport_context);
+
+	memset(in, 0, MLX5_ST_SZ_BYTES(modify_nic_vport_context_in));
+
+	MLX5_SET(modify_nic_vport_context_in, in, vport_number, vport);
+	if (vport)
+		MLX5_SET(modify_nic_vport_context_in, in,
+			 other_vport, 1);
+	MLX5_SET(modify_nic_vport_context_in, in, field_select.promisc, 1);
+	if (promisc_mc)
+		MLX5_SET(nic_vport_context, ctx, promisc_mc, 1);
+	if (promisc_uc)
+		MLX5_SET(nic_vport_context, ctx, promisc_uc, 1);
+	if (promisc_all)
+		MLX5_SET(nic_vport_context, ctx, promisc_all, 1);
+
+	return mlx5_modify_nic_vport_context(mdev, in, sizeof(in));
+}
+EXPORT_SYMBOL_GPL(mlx5_set_nic_vport_promisc);
 int mlx5_set_nic_vport_permanent_mac(struct mlx5_core_dev *mdev, int vport,
 				     u8 *addr)
 {

Modified: stable/10/sys/dev/mlx5/vport.h
==============================================================================
--- stable/10/sys/dev/mlx5/vport.h	Mon Dec 14 10:18:04 2015	(r292195)
+++ stable/10/sys/dev/mlx5/vport.h	Mon Dec 14 10:31:03 2015	(r292196)
@@ -42,6 +42,13 @@ int mlx5_query_nic_vport_mac_address(str
 				     u32 vport, u8 *addr);
 int mlx5_set_nic_vport_current_mac(struct mlx5_core_dev *mdev, int vport,
 				   bool other_vport, u8 *addr);
+int mlx5_set_nic_vport_vlan_list(struct mlx5_core_dev *dev, u32 vport,
+				 u16 *vlan_list, int list_len);
+int mlx5_set_nic_vport_mc_list(struct mlx5_core_dev *mdev, int vport,
+			       u64 *addr_list, size_t addr_list_len);
+int mlx5_set_nic_vport_promisc(struct mlx5_core_dev *mdev, int vport,
+			       bool promisc_mc, bool promisc_uc,
+			       bool promisc_all);
 int mlx5_set_nic_vport_permanent_mac(struct mlx5_core_dev *mdev, int vport,
 				     u8 *addr);
 int mlx5_nic_vport_enable_roce(struct mlx5_core_dev *mdev);

Modified: stable/10/sys/modules/mlx5/Makefile
==============================================================================
--- stable/10/sys/modules/mlx5/Makefile	Mon Dec 14 10:18:04 2015	(r292195)
+++ stable/10/sys/modules/mlx5/Makefile	Mon Dec 14 10:31:03 2015	(r292196)
@@ -7,6 +7,7 @@ mlx5_alloc.c \
 mlx5_cmd.c \
 mlx5_cq.c \
 mlx5_eq.c \
+mlx5_eswitch_vacl.c \
 mlx5_flow_table.c \
 mlx5_fw.c \
 mlx5_health.c \



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201512141031.tBEAV3al036539>