svn commit: r299447 - head/sys/dev/vnic

Zbigniew Bodek zbb at FreeBSD.org
Wed May 11 13:42:21 UTC 2016


Author: zbb
Date: Wed May 11 13:42:20 2016
New Revision: 299447
URL: https://svnweb.freebsd.org/changeset/base/299447

Log:
  Add support for MTU chaning and Jumbo frames to VNIC
  
  Enable previously added code for MTU handling (based on
  Cavium 1.0 driver released on BSD license).
  This commit enables possibility to change MTU on VNIC driver.
  
  Obtained from: Semihalf
  Sponsored by:  Cavium

Modified:
  head/sys/dev/vnic/nicvf_main.c

Modified: head/sys/dev/vnic/nicvf_main.c
==============================================================================
--- head/sys/dev/vnic/nicvf_main.c	Wed May 11 13:38:29 2016	(r299446)
+++ head/sys/dev/vnic/nicvf_main.c	Wed May 11 13:42:20 2016	(r299447)
@@ -138,6 +138,7 @@ static int nicvf_allocate_misc_interrupt
 static int nicvf_enable_misc_interrupt(struct nicvf *);
 static int nicvf_allocate_net_interrupts(struct nicvf *);
 static void nicvf_release_all_interrupts(struct nicvf *);
+static int nicvf_update_hw_max_frs(struct nicvf *, int);
 static int nicvf_hw_set_mac_addr(struct nicvf *, uint8_t *);
 static void nicvf_config_cpi(struct nicvf *);
 static int nicvf_rss_init(struct nicvf *);
@@ -362,7 +363,7 @@ nicvf_setup_ifnet(struct nicvf *nic)
 	if_setcapabilities(ifp, 0);
 
 	/* Set the default values */
-	if_setcapabilitiesbit(ifp, IFCAP_VLAN_MTU, 0);
+	if_setcapabilitiesbit(ifp, IFCAP_VLAN_MTU | IFCAP_JUMBO_MTU, 0);
 	if_setcapabilitiesbit(ifp, IFCAP_LRO, 0);
 	if (nic->hw_tso) {
 		/* TSO */
@@ -465,11 +466,16 @@ nicvf_if_ioctl(struct ifnet *ifp, u_long
 		err = ether_ioctl(ifp, cmd, data);
 		break;
 	case SIOCSIFMTU:
-		/*
-		 * ARM64TODO: Needs to be implemented.
-		 * Currently ETHERMTU is set by default.
-		 */
-		err = ether_ioctl(ifp, cmd, data);
+		if (ifr->ifr_mtu < NIC_HW_MIN_FRS ||
+		    ifr->ifr_mtu > NIC_HW_MAX_FRS) {
+			err = EINVAL;
+		} else {
+			NICVF_CORE_LOCK(nic);
+			err = nicvf_update_hw_max_frs(nic, ifr->ifr_mtu);
+			if (err == 0)
+				if_setmtu(ifp, ifr->ifr_mtu);
+			NICVF_CORE_UNLOCK(nic);
+		}
 		break;
 	case SIOCSIFFLAGS:
 		NICVF_CORE_LOCK(nic);
@@ -974,6 +980,18 @@ nicvf_handle_mbx_intr(struct nicvf *nic)
 }
 
 static int
+nicvf_update_hw_max_frs(struct nicvf *nic, int mtu)
+{
+	union nic_mbx mbx = {};
+
+	mbx.frs.msg = NIC_MBOX_MSG_SET_MAX_FRS;
+	mbx.frs.max_frs = mtu;
+	mbx.frs.vf_id = nic->vf_id;
+
+	return nicvf_send_msg_to_pf(nic, &mbx);
+}
+
+static int
 nicvf_hw_set_mac_addr(struct nicvf *nic, uint8_t *hwaddr)
 {
 	union nic_mbx mbx = {};


More information about the svn-src-head mailing list