Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci/ixgbe - Make SIOCADDMULTI returns ENOSPC when th...



details:   https://anonhg.NetBSD.org/src/rev/8edbafdfd39b
branches:  trunk
changeset: 965298:8edbafdfd39b
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Thu Sep 12 06:19:47 2019 +0000

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

diffstat:

 sys/dev/pci/ixgbe/ixgbe.h    |   4 +---
 sys/dev/pci/ixgbe/ixgbe_vf.c |  10 +++++-----
 sys/dev/pci/ixgbe/ixgbe_vf.h |   4 +++-
 sys/dev/pci/ixgbe/ixv.c      |  38 ++++++++++++++++++++++++++++++++++++--
 4 files changed, 45 insertions(+), 11 deletions(-)

diffs (113 lines):

diff -r 54ef5ae07499 -r 8edbafdfd39b sys/dev/pci/ixgbe/ixgbe.h
--- a/sys/dev/pci/ixgbe/ixgbe.h Thu Sep 12 06:12:56 2019 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe.h Thu Sep 12 06:19:47 2019 +0000
@@ -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 @@
        u64                     flm;
 };
 
-#define IXGBE_MAX_VF_MC 30  /* Max number of multicast entries */
-
 struct ixgbe_vf {
        u_int    pool;
        u_int    rar_index;
diff -r 54ef5ae07499 -r 8edbafdfd39b sys/dev/pci/ixgbe/ixgbe_vf.c
--- a/sys/dev/pci/ixgbe/ixgbe_vf.c      Thu Sep 12 06:12:56 2019 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe_vf.c      Thu Sep 12 06:19:47 2019 +0000
@@ -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 @@
 
        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;
diff -r 54ef5ae07499 -r 8edbafdfd39b sys/dev/pci/ixgbe/ixgbe_vf.h
--- a/sys/dev/pci/ixgbe/ixgbe_vf.h      Thu Sep 12 06:12:56 2019 +0000
+++ b/sys/dev/pci/ixgbe/ixgbe_vf.h      Thu Sep 12 06:19:47 2019 +0000
@@ -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
 
diff -r 54ef5ae07499 -r 8edbafdfd39b sys/dev/pci/ixgbe/ixv.c
--- a/sys/dev/pci/ixgbe/ixv.c   Thu Sep 12 06:12:56 2019 +0000
+++ b/sys/dev/pci/ixgbe/ixv.c   Thu Sep 12 06:19:47 2019 +0000
@@ -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 @@
        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;



Home | Main Index | Thread Index | Old Index