From owner-svn-soc-all@freebsd.org Fri Jul 8 15:46:35 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6EEDAB826BE for ; Fri, 8 Jul 2016 15:46:35 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 53EDC13E5 for ; Fri, 8 Jul 2016 15:46:35 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u68FkZib011099 for ; Fri, 8 Jul 2016 15:46:35 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u68FkYQf011083 for svn-soc-all@FreeBSD.org; Fri, 8 Jul 2016 15:46:34 GMT (envelope-from vincenzo@FreeBSD.org) Date: Fri, 8 Jul 2016 15:46:34 GMT Message-Id: <201607081546.u68FkYQf011083@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r305839 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jul 2016 15:46:35 -0000 Author: vincenzo Date: Fri Jul 8 15:46:34 2016 New Revision: 305839 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=305839 Log: freebsd: ptnet_ioctl: support SIOCSIFMTU Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Fri Jul 8 15:45:53 2016 (r305838) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Fri Jul 8 15:46:34 2016 (r305839) @@ -232,6 +232,7 @@ #define PTNET_RX_BUDGET 512 #define PTNET_TX_BATCH 64 #define PTNET_HDR_SIZE sizeof(struct virtio_net_hdr_mrg_rxbuf) +#define PTNET_MAX_PKT_SIZE 65536 #define PTNET_CSUM_OFFLOAD (CSUM_TCP | CSUM_UDP | CSUM_SCTP) #define PTNET_CSUM_OFFLOAD_IPV6 (CSUM_TCP_IPV6 | CSUM_UDP_IPV6 |\ @@ -710,32 +711,44 @@ int err = 0; switch (cmd) { - case SIOCSIFFLAGS: - device_printf(dev, "SIOCSIFFLAGS %x\n", ifp->if_flags); - PTNET_CORE_LOCK(sc); - if (ifp->if_flags & IFF_UP) { - /* Network stack wants the iff to be up. */ - err = ptnet_init_locked(sc); - } else { - /* Network stack wants the iff to be down. */ - err = ptnet_stop(sc); - } - /* We don't need to do nothing to support IFF_PROMISC, - * since that is managed by the backend port. */ - PTNET_CORE_UNLOCK(sc); - break; + case SIOCSIFFLAGS: + device_printf(dev, "SIOCSIFFLAGS %x\n", ifp->if_flags); + PTNET_CORE_LOCK(sc); + if (ifp->if_flags & IFF_UP) { + /* Network stack wants the iff to be up. */ + err = ptnet_init_locked(sc); + } else { + /* Network stack wants the iff to be down. */ + err = ptnet_stop(sc); + } + /* We don't need to do nothing to support IFF_PROMISC, + * since that is managed by the backend port. */ + PTNET_CORE_UNLOCK(sc); + break; + + case SIOCSIFCAP: + device_printf(dev, "SIOCSIFCAP %x %x\n", + ifr->ifr_reqcap, ifp->if_capenable); + PTNET_CORE_LOCK(sc); + ifp->if_capenable = ifr->ifr_reqcap; + PTNET_CORE_UNLOCK(sc); + break; - case SIOCSIFCAP: - device_printf(dev, "SIOCSIFCAP %x %x\n", - ifr->ifr_reqcap, ifp->if_capenable); + case SIOCSIFMTU: + /* We support any reasonable MTU. */ + if (ifr->ifr_mtu < ETHERMIN || + ifr->ifr_mtu > PTNET_MAX_PKT_SIZE) { + err = EINVAL; + } else { PTNET_CORE_LOCK(sc); - ifp->if_capenable = ifr->ifr_reqcap; + ifp->if_mtu = ifr->ifr_mtu; PTNET_CORE_UNLOCK(sc); - break; + } + break; - default: - err = ether_ioctl(ifp, cmd, data); - break; + default: + err = ether_ioctl(ifp, cmd, data); + break; } return err; @@ -794,7 +807,7 @@ nm_buf_size = NETMAP_BUF_SIZE(na_dr); KASSERT(nm_buf_size > 0, "Invalid netmap buffer size"); - sc->min_tx_space = 65536 / nm_buf_size + 2; + sc->min_tx_space = PTNET_MAX_PKT_SIZE / nm_buf_size + 2; device_printf(sc->dev, "%s: min_tx_space = %u\n", __func__, sc->min_tx_space);