[vlan] Provide vlan_netdev_rx() and vlan_netdev_rx_err()

The Hermon driver uses vlan_find() to identify the appropriate VLAN
device for packets that are received with the VLAN tag already
stripped out by the hardware.  Generalise this capability and expose
it for use by other network card drivers.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2019-04-27 20:12:01 +01:00
parent afee77d816
commit fe680c8228
4 changed files with 84 additions and 21 deletions

View File

@@ -3207,22 +3207,16 @@ static void hermon_eth_complete_recv ( struct ib_device *ibdev __unused,
struct ib_address_vector *source,
struct io_buffer *iobuf, int rc ) {
struct net_device *netdev = ib_qp_get_ownerdata ( qp );
struct net_device *vlan;
unsigned int tag;
/* Find VLAN device, if applicable */
if ( source->vlan_present ) {
if ( ( vlan = vlan_find ( netdev, source->vlan ) ) != NULL ) {
netdev = vlan;
} else if ( rc == 0 ) {
rc = -ENODEV;
}
}
/* Identify VLAN tag, if applicable */
tag = ( source->vlan_present ? source->vlan : 0 );
/* Hand off to network layer */
if ( rc == 0 ) {
netdev_rx ( netdev, iobuf );
vlan_netdev_rx ( netdev, tag, iobuf );
} else {
netdev_rx_err ( netdev, iobuf, rc );
vlan_netdev_rx_err ( netdev, tag, iobuf, rc );
}
}