Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151133084
D31766.id94474.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D31766.id94474.diff
View Options
diff --git a/sys/dev/usb/net/if_cdce.c b/sys/dev/usb/net/if_cdce.c
--- a/sys/dev/usb/net/if_cdce.c
+++ b/sys/dev/usb/net/if_cdce.c
@@ -117,6 +117,7 @@
static void cdce_media_status_cb(struct ifnet *, struct ifmediareq *);
static uint32_t cdce_m_crc32(struct mbuf *, uint32_t, uint32_t);
+static void cdce_set_filter(struct usb_ether *);
#ifdef USB_DEBUG
static int cdce_debug = 0;
@@ -593,6 +594,9 @@
ifmedia_add(&sc->sc_media, IFM_ETHER | IFM_AUTO, 0, NULL);
ifmedia_set(&sc->sc_media, IFM_ETHER | IFM_AUTO);
sc->sc_media.ifm_media = sc->sc_media.ifm_cur->ifm_media;
+ CDCE_LOCK(sc);
+ cdce_set_filter(ue);
+ CDCE_UNLOCK(sc);
return 0;
}
@@ -1025,15 +1029,44 @@
static void
cdce_setmulti(struct usb_ether *ue)
{
- /* no-op */
- return;
+
+ cdce_set_filter(ue);
}
static void
cdce_setpromisc(struct usb_ether *ue)
{
- /* no-op */
- return;
+
+ cdce_set_filter(ue);
+}
+
+static void
+cdce_set_filter(struct usb_ether *ue)
+{
+ struct cdce_softc *sc = uether_getsc(ue);
+ struct ifnet *ifp = uether_getifp(ue);
+ struct usb_device_request req;
+ uint16_t value;
+
+ value = CDC_PACKET_TYPE_DIRECTED | CDC_PACKET_TYPE_BROADCAST;
+ if (if_getflags(ifp) & IFF_PROMISC)
+ value |= CDC_PACKET_TYPE_PROMISC;
+ if (if_getflags(ifp) & IFF_ALLMULTI)
+ value |= CDC_PACKET_TYPE_ALL_MULTICAST;
+
+ req.bmRequestType = UT_CLASS | UT_INTERFACE;
+ req.bRequest = CDC_SET_ETHERNET_PACKET_FILTER;
+ USETW(req.wValue, value);
+ req.wIndex[0] = sc->sc_ifaces_index[1];
+ req.wIndex[1] = 0;
+ USETW(req.wLength, 0);
+
+ /*
+ * Function below will drop the sc mutex.
+ * We can do that since we're called from a separate task,
+ * that simply wraps the setpromisc/setmulti methods.
+ */
+ usbd_do_request(sc->sc_ue.ue_udev, &sc->sc_mtx, &req, NULL);
}
static int
diff --git a/sys/dev/usb/net/if_cdcereg.h b/sys/dev/usb/net/if_cdcereg.h
--- a/sys/dev/usb/net/if_cdcereg.h
+++ b/sys/dev/usb/net/if_cdcereg.h
@@ -37,6 +37,8 @@
#ifndef _USB_IF_CDCEREG_H_
#define _USB_IF_CDCEREG_H_
+#define CDCE_BIT(x) (1 << (x))
+
#define CDCE_FRAMES_MAX 8 /* units */
#define CDCE_IND_SIZE_MAX 32 /* bytes */
@@ -104,6 +106,19 @@
#define CDCE_NOTIFY_DONE 2
};
+/*
+ * Taken from USB CDC Subclass Specification for Ethernet Devices v1.2,
+ * section 6.2.4.
+ */
+
+#define CDC_SET_ETHERNET_PACKET_FILTER 0x43 /* Command code. */
+
+#define CDC_PACKET_TYPE_PROMISC CDCE_BIT(0)
+#define CDC_PACKET_TYPE_ALL_MULTICAST CDCE_BIT(1) /* Allmulti. */
+#define CDC_PACKET_TYPE_DIRECTED CDCE_BIT(2) /* Filter unicast by mac. */
+#define CDC_PACKET_TYPE_BROADCAST CDCE_BIT(3)
+#define CDC_PACKET_TYPE_MULTICAST CDCE_BIT(4) /* Multicast filtering, not supported. */
+
#define CDCE_LOCK(_sc) mtx_lock(&(_sc)->sc_mtx)
#define CDCE_UNLOCK(_sc) mtx_unlock(&(_sc)->sc_mtx)
#define CDCE_LOCK_ASSERT(_sc, t) mtx_assert(&(_sc)->sc_mtx, t)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Apr 7, 7:41 AM (21 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31019150
Default Alt Text
D31766.id94474.diff (2 KB)
Attached To
Mode
D31766: if_cdce: Add support for setting RX filtering
Attached
Detach File
Event Timeline
Log In to Comment