Author: hselasky
Date: Thu Apr 26 08:58:27 2018
New Revision: 333015
URL: https://svnweb.freebsd.org/changeset/base/333015

Log:
  Add network device event for priority code point, PCP, changes.
  
  When the PCP is changed for either a VLAN network interface or when
  prio tagging is enabled for a regular ethernet network interface,
  broadcast the IFNET_EVENT_PCP event so applications like ibcore can
  update its GID tables accordingly.
  
  MFC after:    3 days
  Reviewed by:  ae, kib
  Differential Revision:        https://reviews.freebsd.org/D15040
  Sponsored by: Mellanox Technologies

Modified:
  head/sys/net/if_ethersubr.c
  head/sys/net/if_var.h
  head/sys/net/if_vlan.c

Modified: head/sys/net/if_ethersubr.c
==============================================================================
--- head/sys/net/if_ethersubr.c Thu Apr 26 05:21:00 2018        (r333014)
+++ head/sys/net/if_ethersubr.c Thu Apr 26 08:58:27 2018        (r333015)
@@ -1128,10 +1128,13 @@ ether_ioctl(struct ifnet *ifp, u_long command, caddr_t
                if (error != 0)
                        break;
                if (ifr->ifr_lan_pcp > 7 &&
-                   ifr->ifr_lan_pcp != IFNET_PCP_NONE)
+                   ifr->ifr_lan_pcp != IFNET_PCP_NONE) {
                        error = EINVAL;
-               else
+               } else {
                        ifp->if_pcp = ifr->ifr_lan_pcp;
+                       /* broadcast event about PCP change */
+                       EVENTHANDLER_INVOKE(ifnet_event, ifp, IFNET_EVENT_PCP);
+               }
                break;
 
        case SIOCGLANPCP:

Modified: head/sys/net/if_var.h
==============================================================================
--- head/sys/net/if_var.h       Thu Apr 26 05:21:00 2018        (r333014)
+++ head/sys/net/if_var.h       Thu Apr 26 08:58:27 2018        (r333015)
@@ -421,6 +421,8 @@ EVENTHANDLER_DECLARE(ifnet_link_event, ifnet_link_even
 /* Interface up/down event */
 #define IFNET_EVENT_UP         0
 #define IFNET_EVENT_DOWN       1
+#define IFNET_EVENT_PCP                2       /* priority code point, PCP */
+
 typedef void (*ifnet_event_fn)(void *, struct ifnet *ifp, int event);
 EVENTHANDLER_DECLARE(ifnet_event, ifnet_event_fn);
 #endif /* _SYS_EVENTHANDLER_H_ */

Modified: head/sys/net/if_vlan.c
==============================================================================
--- head/sys/net/if_vlan.c      Thu Apr 26 05:21:00 2018        (r333014)
+++ head/sys/net/if_vlan.c      Thu Apr 26 08:58:27 2018        (r333015)
@@ -1947,6 +1947,8 @@ vlan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data
                }
                ifv->ifv_pcp = ifr->ifr_vlan_pcp;
                vlan_tag_recalculate(ifv);
+               /* broadcast event about PCP change */
+               EVENTHANDLER_INVOKE(ifnet_event, ifp, IFNET_EVENT_PCP);
                break;
 
        case SIOCSIFCAP:
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to