socsvn commit: r303684 - soc2016/vincenzo/head/sys/dev/netmap
vincenzo at FreeBSD.org
vincenzo at FreeBSD.org
Mon May 23 13:37:39 UTC 2016
Author: vincenzo
Date: Mon May 23 13:37:38 2016
New Revision: 303684
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=303684
Log:
ptnet: attach: allocate ethernet interface data structure
The if_alloc() function is called to allocate an Ethernet
interface to represent the ptnet device. Although ptnet
does not have a link speed, we assume 10 Gbps.
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 Mon May 23 13:33:35 2016 (r303683)
+++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Mon May 23 13:37:38 2016 (r303684)
@@ -85,7 +85,8 @@
#include <dev/netmap/netmap_mem2.h>
struct ptnet_softc {
- struct ifnet *ifp;
+ device_t dev;
+ struct ifnet *ifp;
};
static int ptnet_probe(device_t);
@@ -135,11 +136,28 @@
ptnet_attach(device_t dev)
{
struct ptnet_softc *sc;
+ struct ifnet *ifp;
printf("%s\n", __func__);
sc = device_get_softc(dev);
- sc->ifp = NULL;
+ sc->dev = dev;
+ sc->ifp = ifp = if_alloc(IFT_ETHER);
+ if (ifp == NULL) {
+ device_printf(dev, "Failed to allocate ifnet\n");
+ return (ENOMEM);
+ }
+
+ if_initname(ifp, device_get_name(dev), device_get_unit(dev));
+ if_initbaudrate(ifp, IF_Gbps(10));
+ ifp->if_softc = sc;
+ ifp->if_flags = IFF_BROADCAST | IFF_MULTICAST | IFF_SIMPLEX;
+ ifp->if_init = NULL;
+ ifp->if_start = NULL;
+
+ IFQ_SET_MAXLEN(&ifp->if_snd, 255);
+ ifp->if_snd.ifq_drv_maxlen = 255;
+ IFQ_SET_READY(&ifp->if_snd);
return (0);
}
More information about the svn-soc-all
mailing list