Module Name:    src
Committed By:   msaitoh
Date:           Thu Sep 12 06:19:47 UTC 2019

Modified Files:
        src/sys/dev/pci/ixgbe: ixgbe.h ixgbe_vf.c ixgbe_vf.h ixv.c

Log Message:
- Make SIOCADDMULTI returns ENOSPC when the Ethenet multicast address list
  exceeds the limit.
- State "Ethernet" multicast address.
- Use macro.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/pci/ixgbe/ixgbe.h
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/pci/ixgbe/ixgbe_vf.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/pci/ixgbe/ixgbe_vf.h
cvs rdiff -u -r1.131 -r1.132 src/sys/dev/pci/ixgbe/ixv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/pci/ixgbe/ixgbe.h
diff -u src/sys/dev/pci/ixgbe/ixgbe.h:1.56 src/sys/dev/pci/ixgbe/ixgbe.h:1.57
--- src/sys/dev/pci/ixgbe/ixgbe.h:1.56	Wed Jul 17 03:26:24 2019
+++ src/sys/dev/pci/ixgbe/ixgbe.h	Thu Sep 12 06:19:47 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.h,v 1.56 2019/07/17 03:26:24 msaitoh Exp $ */
+/* $NetBSD: ixgbe.h,v 1.57 2019/09/12 06:19:47 msaitoh Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -436,8 +436,6 @@ struct rx_ring {
 	u64			flm;
 };
 
-#define IXGBE_MAX_VF_MC 30  /* Max number of multicast entries */
-
 struct ixgbe_vf {
 	u_int    pool;
 	u_int    rar_index;

Index: src/sys/dev/pci/ixgbe/ixgbe_vf.c
diff -u src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.19 src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.20
--- src/sys/dev/pci/ixgbe/ixgbe_vf.c:1.19	Wed Sep 11 04:59:55 2019
+++ src/sys/dev/pci/ixgbe/ixgbe_vf.c	Thu Sep 12 06:19:47 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_vf.c,v 1.19 2019/09/11 04:59:55 msaitoh Exp $ */
+/* $NetBSD: ixgbe_vf.c,v 1.20 2019/09/12 06:19:47 msaitoh Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -409,11 +409,11 @@ s32 ixgbe_update_mc_addr_list_vf(struct 
 
 	DEBUGOUT1("MC Addr Count = %d\n", mc_addr_count);
 
-	if (mc_addr_count > 30) {
+	if (mc_addr_count > IXGBE_MAX_VF_MC) {
 		device_printf(ixgbe_dev_from_hw(hw),
-		    "number of multicast addresses exceeded the limit "
-		    "(%u > 30)\n", mc_addr_count);
-		cnt = 30;
+		    "number of Ethernet multicast addresses exceeded "
+		    "the limit (%u > %d)\n", mc_addr_count, IXGBE_MAX_VF_MC);
+		cnt = IXGBE_MAX_VF_MC;
 	} else
 		cnt = mc_addr_count;
 	msgbuf[0] = IXGBE_VF_SET_MULTICAST;

Index: src/sys/dev/pci/ixgbe/ixgbe_vf.h
diff -u src/sys/dev/pci/ixgbe/ixgbe_vf.h:1.13 src/sys/dev/pci/ixgbe/ixgbe_vf.h:1.14
--- src/sys/dev/pci/ixgbe/ixgbe_vf.h:1.13	Wed Apr  4 08:13:07 2018
+++ src/sys/dev/pci/ixgbe/ixgbe_vf.h	Thu Sep 12 06:19:47 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe_vf.h,v 1.13 2018/04/04 08:13:07 msaitoh Exp $ */
+/* $NetBSD: ixgbe_vf.h,v 1.14 2019/09/12 06:19:47 msaitoh Exp $ */
 
 /******************************************************************************
   SPDX-License-Identifier: BSD-3-Clause
@@ -42,6 +42,8 @@
 #define IXGBE_VF_MAX_TX_QUEUES	8
 #define IXGBE_VF_MAX_RX_QUEUES	8
 
+#define IXGBE_MAX_VF_MC 30  /* Max number of multicast entries */
+
 /* DCB define */
 #define IXGBE_VF_MAX_TRAFFIC_CLASS	8
 

Index: src/sys/dev/pci/ixgbe/ixv.c
diff -u src/sys/dev/pci/ixgbe/ixv.c:1.131 src/sys/dev/pci/ixgbe/ixv.c:1.132
--- src/sys/dev/pci/ixgbe/ixv.c:1.131	Thu Sep  5 10:01:30 2019
+++ src/sys/dev/pci/ixgbe/ixv.c	Thu Sep 12 06:19:47 2019
@@ -1,4 +1,4 @@
-/*$NetBSD: ixv.c,v 1.131 2019/09/05 10:01:30 msaitoh Exp $*/
+/*$NetBSD: ixv.c,v 1.132 2019/09/12 06:19:47 msaitoh Exp $*/
 
 /******************************************************************************
 
@@ -2920,7 +2920,41 @@ ixv_ioctl(struct ifnet *ifp, u_long comm
 	case SIOCSIFFLAGS:
 		IOCTL_DEBUGOUT("ioctl: SIOCSIFFLAGS (Set Interface Flags)");
 		break;
-	case SIOCADDMULTI:
+	case SIOCADDMULTI: {
+		struct ether_multi *enm;
+		struct ether_multistep step;
+		struct ethercom *ec = &adapter->osdep.ec;
+		int mcnt = 0;
+
+		/*
+		 * Check the number of multicast address. If it exceeds,
+		 * return ENOSPC.
+		 * Update this code when we support API 1.3.
+		 */
+		ETHER_LOCK(ec);
+		ETHER_FIRST_MULTI(step, ec, enm);
+		while (enm != NULL) {
+			mcnt++;
+
+			/*
+			 * This code is before adding, so one room is required
+			 * at least.
+			 */
+			if (mcnt > (IXGBE_MAX_VF_MC - 1)) {
+				device_printf(adapter->dev,
+				    "number of Ethernet multicast addresses "
+				    "exceeds the limit (%d)\n",
+				    IXGBE_MAX_VF_MC);
+				error = ENOSPC;
+				break;
+			}
+			ETHER_NEXT_MULTI(step, enm);
+		}
+		ETHER_UNLOCK(ec);
+		if (error)
+			return error;
+	}
+		/*FALLTHROUGH*/
 	case SIOCDELMULTI:
 		IOCTL_DEBUGOUT("ioctl: SIOC(ADD|DEL)MULTI");
 		break;

Reply via email to