* [PATCH 1/3] deinline a few large functions in vlan code - v3
@ 2006-04-11 7:43 Denis Vlasenko
2006-04-11 7:44 ` [PATCH 2/3] " Denis Vlasenko
0 siblings, 1 reply; 7+ messages in thread
From: Denis Vlasenko @ 2006-04-11 7:43 UTC (permalink / raw)
To: David S. Miller, jgarzik, linux-kernel, linux-net, netdev
[-- Attachment #1: Type: text/plain, Size: 496 bytes --]
Hi,
After davem and Dave Dillow comments I realized that
a lot of drivers try to do VLAN-related things even on
non-VLAN-enabled kernels.
These patches exclude VLAN code from netdevice drivers
and from bonding module, and even remove vlan-related
members of struct netdevice if VLAN is not configured.
Compile tested on allyesconfig kernel with CONFIG_8021Q=y,m,n.
Below is a patch which takes care of drivers/net/*.
Please comment.
Signed-off-by: Denis Vlasenko <vda@ilport.com.ua>
--
vda
[-- Attachment #2: 2.6.16.vlan_inline5_drivers.patch --]
[-- Type: text/x-diff, Size: 24202 bytes --]
diff -urpN linux-2.6.16.org/drivers/net/bnx2.c linux-2.6.16.vlan/drivers/net/bnx2.c
--- linux-2.6.16.org/drivers/net/bnx2.c Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/drivers/net/bnx2.c Tue Apr 11 10:15:58 2006
@@ -4436,10 +4436,13 @@ bnx2_start_xmit(struct sk_buff *skb, str
vlan_tag_flags |= TX_BD_FLAGS_TCP_UDP_CKSUM;
}
+#ifdef BCM_VLAN
if (bp->vlgrp != 0 && vlan_tx_tag_present(skb)) {
vlan_tag_flags |=
(TX_BD_FLAGS_VLAN_TAG | (vlan_tx_tag_get(skb) << 16));
}
+#endif
+
#ifdef BCM_TSO
if ((mss = skb_shinfo(skb)->tso_size) &&
(skb->len > (bp->dev->mtu + ETH_HLEN))) {
diff -urpN linux-2.6.16.org/drivers/net/bnx2.h linux-2.6.16.vlan/drivers/net/bnx2.h
--- linux-2.6.16.org/drivers/net/bnx2.h Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/drivers/net/bnx2.h Tue Apr 11 10:15:58 2006
@@ -40,7 +40,9 @@
#include <linux/mii.h>
#ifdef NETIF_F_HW_VLAN_TX
#include <linux/if_vlan.h>
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
#define BCM_VLAN 1
+#endif
#endif
#ifdef NETIF_F_TSO
#include <net/ip.h>
diff -urpN linux-2.6.16.org/drivers/net/chelsio/sge.c linux-2.6.16.vlan/drivers/net/chelsio/sge.c
--- linux-2.6.16.org/drivers/net/chelsio/sge.c Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/drivers/net/chelsio/sge.c Tue Apr 11 10:15:58 2006
@@ -978,6 +978,7 @@ static int sge_rx(struct sge *sge, struc
} else
skb->ip_summed = CHECKSUM_NONE;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (unlikely(adapter->vlan_grp && p->vlan_valid)) {
sge->port_stats[p->iff].vlan_xtract++;
if (adapter->params.sge.polling)
@@ -986,7 +987,9 @@ static int sge_rx(struct sge *sge, struc
else
vlan_hwaccel_rx(skb, adapter->vlan_grp,
ntohs(p->vlan));
- } else if (adapter->params.sge.polling)
+ } else
+#endif
+ if (adapter->params.sge.polling)
netif_receive_skb(skb);
else
netif_rx(skb);
diff -urpN linux-2.6.16.org/drivers/net/e1000/e1000.h linux-2.6.16.vlan/drivers/net/e1000/e1000.h
--- linux-2.6.16.org/drivers/net/e1000/e1000.h Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/drivers/net/e1000/e1000.h Tue Apr 11 10:15:58 2006
@@ -254,8 +254,10 @@ struct e1000_adapter {
struct timer_list tx_fifo_stall_timer;
struct timer_list watchdog_timer;
struct timer_list phy_info_timer;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
struct vlan_group *vlgrp;
uint16_t mng_vlan_id;
+#endif
uint32_t bd_number;
uint32_t rx_buffer_len;
uint32_t part_num;
diff -urpN linux-2.6.16.org/drivers/net/e1000/e1000_main.c linux-2.6.16.vlan/drivers/net/e1000/e1000_main.c
--- linux-2.6.16.org/drivers/net/e1000/e1000_main.c Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/drivers/net/e1000/e1000_main.c Tue Apr 11 10:15:59 2006
@@ -250,10 +250,12 @@ static void e1000_smartspeed(struct e100
static inline int e1000_82547_fifo_workaround(struct e1000_adapter *adapter,
struct sk_buff *skb);
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
static void e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp);
static void e1000_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
static void e1000_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
static void e1000_restore_vlan(struct e1000_adapter *adapter);
+#endif
#ifdef CONFIG_PM
static int e1000_suspend(struct pci_dev *pdev, pm_message_t state);
@@ -361,6 +363,7 @@ e1000_irq_enable(struct e1000_adapter *a
}
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
static void
e1000_update_mng_vlan(struct e1000_adapter *adapter)
{
@@ -383,6 +386,7 @@ e1000_update_mng_vlan(struct e1000_adapt
}
}
}
+#endif
/**
* e1000_release_hw_control - release control of the h/w to f/w
@@ -470,7 +474,9 @@ e1000_up(struct e1000_adapter *adapter)
e1000_set_multi(netdev);
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
e1000_restore_vlan(adapter);
+#endif
e1000_configure_tx(adapter);
e1000_setup_rctl(adapter);
@@ -629,9 +635,12 @@ e1000_reset(struct e1000_adapter *adapte
E1000_WRITE_REG(&adapter->hw, WUC, 0);
if (e1000_init_hw(&adapter->hw))
DPRINTK(PROBE, ERR, "Hardware Error\n");
+
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
e1000_update_mng_vlan(adapter);
/* Enable h/w to recognize an 802.1Q VLAN Ethernet packet */
E1000_WRITE_REG(&adapter->hw, VET, ETHERNET_IEEE_VLAN_TYPE);
+#endif
e1000_reset_adaptive(&adapter->hw);
e1000_phy_get_info(&adapter->hw, &adapter->phy_info);
@@ -733,9 +742,11 @@ e1000_probe(struct pci_dev *pdev,
netdev->poll = &e1000_clean;
netdev->weight = 64;
#endif
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
netdev->vlan_rx_register = e1000_vlan_rx_register;
netdev->vlan_rx_add_vid = e1000_vlan_rx_add_vid;
netdev->vlan_rx_kill_vid = e1000_vlan_rx_kill_vid;
+#endif
#ifdef CONFIG_NET_POLL_CONTROLLER
netdev->poll_controller = e1000_netpoll;
#endif
@@ -1228,11 +1239,14 @@ e1000_open(struct net_device *netdev)
if ((err = e1000_up(adapter)))
goto err_up;
+
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
if ((adapter->hw.mng_cookie.status &
E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
e1000_update_mng_vlan(adapter);
}
+#endif
/* If AMT is enabled, let the firmware know that the network
* interface is now open */
@@ -1274,10 +1288,12 @@ e1000_close(struct net_device *netdev)
e1000_free_all_tx_resources(adapter);
e1000_free_all_rx_resources(adapter);
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if ((adapter->hw.mng_cookie.status &
E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT)) {
e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
}
+#endif
/* If AMT is enabled, let the firmware know that the network
* interface is now closed */
@@ -2397,8 +2413,10 @@ e1000_watchdog_task(struct e1000_adapter
e1000_check_for_link(&adapter->hw);
if (adapter->hw.mac_type == e1000_82573) {
e1000_enable_tx_pkt_filtering(&adapter->hw);
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (adapter->mng_vlan_id != adapter->hw.mng_cookie.vlan_id)
e1000_update_mng_vlan(adapter);
+#endif
}
if ((adapter->hw.media_type == e1000_media_type_internal_serdes) &&
@@ -2985,10 +3003,12 @@ e1000_xmit_frame(struct sk_buff *skb, st
}
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (unlikely(adapter->vlgrp && vlan_tx_tag_present(skb))) {
tx_flags |= E1000_TX_FLAGS_VLAN;
tx_flags |= (vlan_tx_tag_get(skb) << E1000_TX_FLAGS_VLAN_SHIFT);
}
+#endif
first = tx_ring->next_to_use;
@@ -3714,23 +3734,25 @@ e1000_clean_rx_irq(struct e1000_adapter
skb->protocol = eth_type_trans(skb, netdev);
#ifdef CONFIG_E1000_NAPI
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (unlikely(adapter->vlgrp &&
(status & E1000_RXD_STAT_VP))) {
vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
le16_to_cpu(rx_desc->special) &
E1000_RXD_SPC_VLAN_MASK);
- } else {
+ } else
+#endif
netif_receive_skb(skb);
- }
#else /* CONFIG_E1000_NAPI */
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (unlikely(adapter->vlgrp &&
(status & E1000_RXD_STAT_VP))) {
vlan_hwaccel_rx(skb, adapter->vlgrp,
le16_to_cpu(rx_desc->special) &
E1000_RXD_SPC_VLAN_MASK);
- } else {
+ } else
+#endif
netif_rx(skb);
- }
#endif /* CONFIG_E1000_NAPI */
netdev->last_rx = jiffies;
#ifdef CONFIG_E1000_MQ
@@ -3861,21 +3883,23 @@ e1000_clean_rx_irq_ps(struct e1000_adapt
cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP)))
adapter->rx_hdr_split++;
#ifdef CONFIG_E1000_NAPI
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
le16_to_cpu(rx_desc->wb.middle.vlan) &
E1000_RXD_SPC_VLAN_MASK);
- } else {
+ } else
+#endif
netif_receive_skb(skb);
- }
#else /* CONFIG_E1000_NAPI */
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (unlikely(adapter->vlgrp && (staterr & E1000_RXD_STAT_VP))) {
vlan_hwaccel_rx(skb, adapter->vlgrp,
le16_to_cpu(rx_desc->wb.middle.vlan) &
E1000_RXD_SPC_VLAN_MASK);
- } else {
+ } else
+#endif
netif_rx(skb);
- }
#endif /* CONFIG_E1000_NAPI */
netdev->last_rx = jiffies;
#ifdef CONFIG_E1000_MQ
@@ -4351,6 +4375,7 @@ e1000_io_write(struct e1000_hw *hw, unsi
outl(value, port);
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
static void
e1000_vlan_rx_register(struct net_device *netdev, struct vlan_group *grp)
{
@@ -4382,10 +4407,12 @@ e1000_vlan_rx_register(struct net_device
rctl = E1000_READ_REG(&adapter->hw, RCTL);
rctl &= ~E1000_RCTL_VFE;
E1000_WRITE_REG(&adapter->hw, RCTL, rctl);
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (adapter->mng_vlan_id != (uint16_t)E1000_MNG_VLAN_NONE) {
e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);
adapter->mng_vlan_id = E1000_MNG_VLAN_NONE;
}
+#endif
}
e1000_irq_enable(adapter);
@@ -4450,6 +4477,7 @@ e1000_restore_vlan(struct e1000_adapter
}
}
}
+#endif
int
e1000_set_spd_dplx(struct e1000_adapter *adapter, uint16_t spddplx)
diff -urpN linux-2.6.16.org/drivers/net/gianfar.c linux-2.6.16.vlan/drivers/net/gianfar.c
--- linux-2.6.16.org/drivers/net/gianfar.c Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/drivers/net/gianfar.c Tue Apr 11 10:15:59 2006
@@ -270,6 +270,7 @@ static int gfar_probe(struct platform_de
} else
priv->rx_csum_enable = 0;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
priv->vlgrp = NULL;
if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_VLAN) {
@@ -280,6 +281,7 @@ static int gfar_probe(struct platform_de
priv->vlan_enable = 1;
}
+#endif
if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_EXTENDED_HASH) {
priv->extended_hash = 1;
@@ -792,8 +794,10 @@ int startup_gfar(struct net_device *dev)
rctrl |= RCTRL_EMEN;
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (priv->vlan_enable)
rctrl |= RCTRL_VLAN;
+#endif
if (priv->padding) {
rctrl &= ~RCTRL_PAL_MASK;
@@ -945,6 +949,7 @@ static int gfar_start_xmit(struct sk_buf
gfar_tx_checksum(skb, fcb);
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (priv->vlan_enable &&
unlikely(priv->vlgrp && vlan_tx_tag_present(skb))) {
if (unlikely(NULL == fcb)) {
@@ -954,6 +959,7 @@ static int gfar_start_xmit(struct sk_buf
gfar_tx_vlan(skb, fcb);
}
+#endif
/* Set buffer length and pointer */
txbdp->length = skb->len;
@@ -1037,6 +1043,7 @@ int gfar_set_mac_address(struct net_devi
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
/* Enables and disables VLAN insertion/extraction */
static void gfar_vlan_rx_register(struct net_device *dev,
struct vlan_group *grp)
@@ -1074,8 +1081,10 @@ static void gfar_vlan_rx_register(struct
spin_unlock_irqrestore(&priv->lock, flags);
}
+#endif
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
static void gfar_vlan_rx_kill_vid(struct net_device *dev, uint16_t vid)
{
struct gfar_private *priv = netdev_priv(dev);
@@ -1088,6 +1097,7 @@ static void gfar_vlan_rx_kill_vid(struct
spin_unlock_irqrestore(&priv->lock, flags);
}
+#endif
static int gfar_change_mtu(struct net_device *dev, int new_mtu)
@@ -1097,8 +1107,10 @@ static int gfar_change_mtu(struct net_de
int oldsize = priv->rx_buffer_size;
int frame_size = new_mtu + ETH_HLEN;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (priv->vlan_enable)
frame_size += VLAN_ETH_HLEN;
+#endif
if (gfar_uses_fcb(priv))
frame_size += GMAC_FCB_LEN;
@@ -1343,6 +1355,7 @@ irqreturn_t gfar_receive(int irq, void *
return IRQ_HANDLED;
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
static inline int gfar_rx_vlan(struct sk_buff *skb,
struct vlan_group *vlgrp, unsigned short vlctl)
{
@@ -1352,6 +1365,7 @@ static inline int gfar_rx_vlan(struct sk
return vlan_hwaccel_rx(skb, vlgrp, vlctl);
#endif
}
+#endif
static inline void gfar_rx_checksum(struct sk_buff *skb, struct rxfcb *fcb)
{
@@ -1409,9 +1423,11 @@ static int gfar_process_frame(struct net
skb->protocol = eth_type_trans(skb, dev);
/* Send the packet up the stack */
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (unlikely(priv->vlgrp && (fcb->flags & RXFCB_VLN)))
ret = gfar_rx_vlan(skb, priv->vlgrp, fcb->vlctl);
else
+#endif
ret = RECEIVE(skb);
if (NET_RX_DROP == ret)
diff -urpN linux-2.6.16.org/drivers/net/gianfar.h linux-2.6.16.vlan/drivers/net/gianfar.h
--- linux-2.6.16.org/drivers/net/gianfar.h Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/drivers/net/gianfar.h Tue Apr 11 10:15:59 2006
@@ -702,7 +702,9 @@ struct gfar_private {
extended_hash:1,
bd_stash_en:1;
unsigned short padding;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
struct vlan_group *vlgrp;
+#endif
/* Info structure initialized by board setup code */
unsigned int interruptTransmit;
unsigned int interruptReceive;
diff -urpN linux-2.6.16.org/drivers/net/ixgb/ixgb.h linux-2.6.16.vlan/drivers/net/ixgb/ixgb.h
--- linux-2.6.16.org/drivers/net/ixgb/ixgb.h Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/drivers/net/ixgb/ixgb.h Tue Apr 11 10:15:59 2006
@@ -155,7 +155,9 @@ struct ixgb_desc_ring {
struct ixgb_adapter {
struct timer_list watchdog_timer;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
struct vlan_group *vlgrp;
+#endif
uint32_t bd_number;
uint32_t rx_buffer_len;
uint32_t part_num;
diff -urpN linux-2.6.16.org/drivers/net/ixgb/ixgb_main.c linux-2.6.16.vlan/drivers/net/ixgb/ixgb_main.c
--- linux-2.6.16.org/drivers/net/ixgb/ixgb_main.c Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/drivers/net/ixgb/ixgb_main.c Tue Apr 11 10:15:59 2006
@@ -121,11 +121,13 @@ static void ixgb_alloc_rx_buffers(struct
void ixgb_set_ethtool_ops(struct net_device *netdev);
static void ixgb_tx_timeout(struct net_device *dev);
static void ixgb_tx_timeout_task(struct net_device *dev);
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
static void ixgb_vlan_rx_register(struct net_device *netdev,
struct vlan_group *grp);
static void ixgb_vlan_rx_add_vid(struct net_device *netdev, uint16_t vid);
static void ixgb_vlan_rx_kill_vid(struct net_device *netdev, uint16_t vid);
static void ixgb_restore_vlan(struct ixgb_adapter *adapter);
+#endif
#ifdef CONFIG_NET_POLL_CONTROLLER
/* for netdump / net console */
@@ -233,7 +235,9 @@ ixgb_up(struct ixgb_adapter *adapter)
ixgb_set_multi(netdev);
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
ixgb_restore_vlan(adapter);
+#endif
ixgb_configure_tx(adapter);
ixgb_setup_rctl(adapter);
@@ -419,9 +423,11 @@ ixgb_probe(struct pci_dev *pdev,
netdev->poll = &ixgb_clean;
netdev->weight = 64;
#endif
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
netdev->vlan_rx_register = ixgb_vlan_rx_register;
netdev->vlan_rx_add_vid = ixgb_vlan_rx_add_vid;
netdev->vlan_rx_kill_vid = ixgb_vlan_rx_kill_vid;
+#endif
#ifdef CONFIG_NET_POLL_CONTROLLER
netdev->poll_controller = ixgb_netpoll;
#endif
@@ -1398,10 +1404,12 @@ ixgb_xmit_frame(struct sk_buff *skb, str
}
spin_unlock_irqrestore(&adapter->tx_lock, flags);
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if(adapter->vlgrp && vlan_tx_tag_present(skb)) {
tx_flags |= IXGB_TX_FLAGS_VLAN;
vlan_id = vlan_tx_tag_get(skb);
}
+#endif
first = adapter->tx_ring.next_to_use;
@@ -1905,21 +1913,23 @@ ixgb_clean_rx_irq(struct ixgb_adapter *a
skb->protocol = eth_type_trans(skb, netdev);
#ifdef CONFIG_IXGB_NAPI
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if(adapter->vlgrp && (status & IXGB_RX_DESC_STATUS_VP)) {
vlan_hwaccel_receive_skb(skb, adapter->vlgrp,
le16_to_cpu(rx_desc->special) &
IXGB_RX_DESC_SPECIAL_VLAN_MASK);
- } else {
+ } else
+#endif
netif_receive_skb(skb);
- }
#else /* CONFIG_IXGB_NAPI */
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if(adapter->vlgrp && (status & IXGB_RX_DESC_STATUS_VP)) {
vlan_hwaccel_rx(skb, adapter->vlgrp,
le16_to_cpu(rx_desc->special) &
IXGB_RX_DESC_SPECIAL_VLAN_MASK);
- } else {
+ } else
+#endif
netif_rx(skb);
- }
#endif /* CONFIG_IXGB_NAPI */
netdev->last_rx = jiffies;
@@ -2014,6 +2024,7 @@ ixgb_alloc_rx_buffers(struct ixgb_adapte
rx_ring->next_to_use = i;
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
/**
* ixgb_vlan_rx_register - enables or disables vlan tagging/stripping.
*
@@ -2107,6 +2118,7 @@ ixgb_restore_vlan(struct ixgb_adapter *a
}
}
}
+#endif /* defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) */
#ifdef CONFIG_NET_POLL_CONTROLLER
/*
diff -urpN linux-2.6.16.org/drivers/net/s2io.c linux-2.6.16.vlan/drivers/net/s2io.c
--- linux-2.6.16.org/drivers/net/s2io.c Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/drivers/net/s2io.c Tue Apr 11 10:15:59 2006
@@ -182,6 +182,7 @@ static char ethtool_stats_keys[][ETH_GST
timer.data = (unsigned long) arg; \
mod_timer(&timer, (jiffies + exp)) \
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
/* Add the vlan */
static void s2io_vlan_rx_register(struct net_device *dev,
struct vlan_group *grp)
@@ -205,6 +206,7 @@ static void s2io_vlan_rx_kill_vid(struct
nic->vlgrp->vlan_devices[vid] = NULL;
spin_unlock_irqrestore(&nic->tx_lock, flags);
}
+#endif
/*
* Constants to be programmed into the Xena's registers, to configure
@@ -3469,8 +3471,10 @@ static int s2io_xmit(struct sk_buff *skb
#ifdef NETIF_F_TSO
int mss;
#endif
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
u16 vlan_tag = 0;
int vlan_priority = 0;
+#endif
mac_info_t *mac_control;
struct config_param *config;
@@ -3489,12 +3493,14 @@ static int s2io_xmit(struct sk_buff *skb
queue = 0;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
/* Get Fifo number to Transmit based on vlan priority */
if (sp->vlgrp && vlan_tx_tag_present(skb)) {
vlan_tag = vlan_tx_tag_get(skb);
vlan_priority = vlan_tag >> 13;
queue = config->fifo_mapping[vlan_priority];
}
+#endif
put_off = (u16) mac_control->fifos[queue].tx_curr_put_info.offset;
get_off = (u16) mac_control->fifos[queue].tx_curr_get_info.offset;
@@ -3537,10 +3543,12 @@ static int s2io_xmit(struct sk_buff *skb
txdp->Control_1 |= TXD_LIST_OWN_XENA;
txdp->Control_2 |= config->tx_intr_type;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (sp->vlgrp && vlan_tx_tag_present(skb)) {
txdp->Control_2 |= TXD_VLAN_ENABLE;
txdp->Control_2 |= TXD_VLAN_TAG(vlan_tag);
}
+#endif
frg_len = skb->len - skb->data_len;
if (skb_shinfo(skb)->ufo_size) {
@@ -5680,21 +5688,23 @@ static int rx_osm_handler(ring_info_t *r
skb->protocol = eth_type_trans(skb, dev);
#ifdef CONFIG_S2IO_NAPI
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (sp->vlgrp && RXD_GET_VLAN_TAG(rxdp->Control_2)) {
/* Queueing the vlan frame to the upper layer */
vlan_hwaccel_receive_skb(skb, sp->vlgrp,
RXD_GET_VLAN_TAG(rxdp->Control_2));
- } else {
+ } else
+#endif
netif_receive_skb(skb);
- }
#else
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (sp->vlgrp && RXD_GET_VLAN_TAG(rxdp->Control_2)) {
/* Queueing the vlan frame to the upper layer */
vlan_hwaccel_rx(skb, sp->vlgrp,
RXD_GET_VLAN_TAG(rxdp->Control_2));
- } else {
+ } else
+#endif
netif_rx(skb);
- }
#endif
dev->last_rx = jiffies;
atomic_dec(&sp->rx_bufs_left[ring_no]);
@@ -6051,9 +6061,11 @@ Defaulting to INTA\n");
dev->do_ioctl = &s2io_ioctl;
dev->change_mtu = &s2io_change_mtu;
SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX;
dev->vlan_rx_register = s2io_vlan_rx_register;
dev->vlan_rx_kill_vid = (void *)s2io_vlan_rx_kill_vid;
+#endif
/*
* will use eth_mac_addr() for dev->set_mac_address
diff -urpN linux-2.6.16.org/drivers/net/s2io.h linux-2.6.16.vlan/drivers/net/s2io.h
--- linux-2.6.16.org/drivers/net/s2io.h Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/drivers/net/s2io.h Tue Apr 11 10:15:59 2006
@@ -771,7 +771,9 @@ struct s2io_nic {
#define CARD_UP 2
atomic_t card_state;
volatile unsigned long link_state;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
struct vlan_group *vlgrp;
+#endif
#define MSIX_FLG 0xA5
struct msix_entry *entries;
struct s2io_msix_entry *s2io_entries;
diff -urpN linux-2.6.16.org/drivers/net/typhoon.c linux-2.6.16.vlan/drivers/net/typhoon.c
--- linux-2.6.16.org/drivers/net/typhoon.c Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/drivers/net/typhoon.c Tue Apr 11 10:21:19 2006
@@ -285,7 +285,9 @@ struct typhoon {
struct pci_dev * pdev;
struct net_device * dev;
spinlock_t state_lock;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
struct vlan_group * vlgrp;
+#endif
struct basic_ring rxHiRing;
struct basic_ring rxBuffRing;
struct rxbuff_ent rxbuffers[RXENT_ENTRIES];
@@ -707,6 +709,7 @@ out:
return err;
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
static void
typhoon_vlan_rx_register(struct net_device *dev, struct vlan_group *grp)
{
@@ -754,6 +757,7 @@ typhoon_vlan_rx_kill_vid(struct net_devi
tp->vlgrp->vlan_devices[vid] = NULL;
spin_unlock_bh(&tp->state_lock);
}
+#endif
static inline void
typhoon_tso_fill(struct sk_buff *skb, struct transmit_ring *txRing,
@@ -837,6 +841,7 @@ typhoon_start_tx(struct sk_buff *skb, st
first_txd->processFlags |= TYPHOON_TX_PF_IP_CHKSUM;
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if(vlan_tx_tag_present(skb)) {
first_txd->processFlags |=
TYPHOON_TX_PF_INSERT_VLAN | TYPHOON_TX_PF_VLAN_PRIORITY;
@@ -844,6 +849,7 @@ typhoon_start_tx(struct sk_buff *skb, st
cpu_to_le32(htons(vlan_tx_tag_get(skb)) <<
TYPHOON_TX_PF_VLAN_TAG_SHIFT);
}
+#endif
if(skb_tso_size(skb)) {
first_txd->processFlags |= TYPHOON_TX_PF_TCP_SEGMENT;
@@ -1744,13 +1750,15 @@ typhoon_rx(struct typhoon *tp, struct ba
} else
new_skb->ip_summed = CHECKSUM_NONE;
- spin_lock(&tp->state_lock);
- if(tp->vlgrp != NULL && rx->rxStatus & TYPHOON_RX_VLAN)
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
+ if(tp->vlgrp != NULL && rx->rxStatus & TYPHOON_RX_VLAN) {
+ spin_lock(&tp->state_lock);
vlan_hwaccel_receive_skb(new_skb, tp->vlgrp,
ntohl(rx->vlanTag) & 0xffff);
- else
+ spin_unlock(&tp->state_lock);
+ } else
+#endif
netif_receive_skb(new_skb);
- spin_unlock(&tp->state_lock);
tp->dev->last_rx = jiffies;
received++;
@@ -2232,6 +2240,7 @@ typhoon_suspend(struct pci_dev *pdev, pm
if(!netif_running(dev))
return 0;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
spin_lock_bh(&tp->state_lock);
if(tp->vlgrp && tp->wol_events & TYPHOON_WAKE_MAGIC_PKT) {
spin_unlock_bh(&tp->state_lock);
@@ -2240,6 +2249,7 @@ typhoon_suspend(struct pci_dev *pdev, pm
return -EBUSY;
}
spin_unlock_bh(&tp->state_lock);
+#endif
netif_device_detach(dev);
@@ -2549,8 +2559,10 @@ typhoon_init_one(struct pci_dev *pdev, c
dev->watchdog_timeo = TX_TIMEOUT;
dev->get_stats = typhoon_get_stats;
dev->set_mac_address = typhoon_set_mac_address;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
dev->vlan_rx_register = typhoon_vlan_rx_register;
dev->vlan_rx_kill_vid = typhoon_vlan_rx_kill_vid;
+#endif
SET_ETHTOOL_OPS(dev, &typhoon_ethtool_ops);
/* We can handle scatter gather, up to 16 entries, and
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/3] deinline a few large functions in vlan code - v3
2006-04-11 7:43 [PATCH 1/3] deinline a few large functions in vlan code - v3 Denis Vlasenko
@ 2006-04-11 7:44 ` Denis Vlasenko
2006-04-11 7:47 ` [PATCH 3/3] " Denis Vlasenko
0 siblings, 1 reply; 7+ messages in thread
From: Denis Vlasenko @ 2006-04-11 7:44 UTC (permalink / raw)
To: David S. Miller; +Cc: jgarzik, linux-kernel, linux-net, netdev
[-- Attachment #1: Type: text/plain, Size: 356 bytes --]
On Tuesday 11 April 2006 10:43, Denis Vlasenko wrote:
> These patches exclude VLAN code from netdevice drivers
> and from bonding module, and even remove vlan-related
> members of struct netdevice if VLAN is not configured.
>
> Compile tested on allyesconfig kernel with CONFIG_8021Q=y,m,n.
This one takes care of drivers/net/bonding/bonding.[ch]
--
vda
[-- Attachment #2: 2.6.16.vlan_inline5_bonding.patch --]
[-- Type: text/x-diff, Size: 12407 bytes --]
diff -urpN linux-2.6.16.org/drivers/net/bonding/bond_alb.c linux-2.6.16.vlan/drivers/net/bonding/bond_alb.c
--- linux-2.6.16.org/drivers/net/bonding/bond_alb.c Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/drivers/net/bonding/bond_alb.c Tue Apr 11 10:15:58 2006
@@ -502,6 +502,7 @@ static void rlb_update_client(struct rlb
skb->dev = client_info->slave->dev;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (client_info->tag) {
skb = vlan_put_tag(skb, client_info->vlan_id);
if (!skb) {
@@ -511,7 +512,7 @@ static void rlb_update_client(struct rlb
continue;
}
}
-
+#endif
arp_xmit(skb);
}
}
@@ -671,6 +672,7 @@ static struct slave *rlb_choose_channel(
client_info->ntt = 0;
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (!list_empty(&bond->vlan_list)) {
unsigned short vlan_id;
int res = vlan_get_tag(skb, &vlan_id);
@@ -679,6 +681,7 @@ static struct slave *rlb_choose_channel(
client_info->vlan_id = vlan_id;
}
}
+#endif
if (!client_info->assigned) {
u32 prev_tbl_head = bond_info->rx_hashtbl_head;
@@ -833,6 +836,7 @@ static void rlb_deinitialize(struct bond
_unlock_rx_hashtbl(bond);
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
static void rlb_clear_vlan(struct bonding *bond, unsigned short vlan_id)
{
struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
@@ -865,12 +869,15 @@ static void rlb_clear_vlan(struct bondin
_unlock_rx_hashtbl(bond);
}
+#endif
/*********************** tlb/rlb shared functions *********************/
static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[])
{
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
struct bonding *bond = bond_get_bond_by_slave(slave);
+#endif
struct learning_pkt pkt;
int size = sizeof(struct learning_pkt);
int i;
@@ -898,6 +905,7 @@ static void alb_send_learning_packets(st
skb->priority = TC_PRIO_CONTROL;
skb->dev = slave->dev;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (!list_empty(&bond->vlan_list)) {
struct vlan_entry *vlan;
@@ -918,7 +926,7 @@ static void alb_send_learning_packets(st
continue;
}
}
-
+#endif
dev_queue_xmit(skb);
}
}
@@ -1665,6 +1673,7 @@ int bond_alb_set_mac_address(struct net_
return 0;
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id)
{
if (bond->alb_info.current_alb_vlan &&
@@ -1676,4 +1685,4 @@ void bond_alb_clear_vlan(struct bonding
rlb_clear_vlan(bond, vlan_id);
}
}
-
+#endif
diff -urpN linux-2.6.16.org/drivers/net/bonding/bond_main.c linux-2.6.16.vlan/drivers/net/bonding/bond_main.c
--- linux-2.6.16.org/drivers/net/bonding/bond_main.c Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/drivers/net/bonding/bond_main.c Tue Apr 11 10:15:58 2006
@@ -199,6 +199,7 @@ const char *bond_mode_name(int mode)
}
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
/*---------------------------------- VLAN -----------------------------------*/
/**
@@ -349,6 +350,7 @@ struct vlan_entry *bond_next_vlan(struct
return next;
}
+#endif
/**
* bond_dev_queue_xmit - Prepare skb for xmit.
@@ -366,6 +368,7 @@ struct vlan_entry *bond_next_vlan(struct
*/
int bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev)
{
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
unsigned short vlan_id;
if (!list_empty(&bond->vlan_list) &&
@@ -380,9 +383,9 @@ int bond_dev_queue_xmit(struct bonding *
*/
return 0;
}
- } else {
+ } else
+#endif
skb->dev = slave_dev;
- }
skb->priority = 1;
dev_queue_xmit(skb);
@@ -390,6 +393,7 @@ int bond_dev_queue_xmit(struct bonding *
return 0;
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
/*
* In the following 3 functions, bond_vlan_rx_register(), bond_vlan_rx_add_vid
* and bond_vlan_rx_kill_vid, We don't protect the slave list iteration with a
@@ -555,6 +559,7 @@ unreg:
out:
write_unlock_bh(&bond->lock);
}
+#endif /* defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE) */
/*------------------------------- Link status -------------------------------*/
@@ -1215,6 +1220,7 @@ int bond_enslave(struct net_device *bond
return -EBUSY;
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
/* vlan challenged mutual exclusion */
/* no need to lock since we're protected by rtnl_lock */
if (slave_dev->features & NETIF_F_VLAN_CHALLENGED) {
@@ -1244,6 +1250,7 @@ int bond_enslave(struct net_device *bond
bond_dev->features &= ~NETIF_F_VLAN_CHALLENGED;
}
}
+#endif
/*
* Old ifenslave binaries are no longer supported. These can
@@ -1356,7 +1363,9 @@ int bond_enslave(struct net_device *bond
dev_mc_add(slave_dev, lacpdu_multicast, ETH_ALEN, 0);
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
bond_add_vlans_on_slave(bond, slave_dev);
+#endif
write_lock_bh(&bond->lock);
@@ -1667,6 +1676,7 @@ int bond_release(struct net_device *bond
*/
memset(bond_dev->dev_addr, 0, bond_dev->addr_len);
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (list_empty(&bond->vlan_list)) {
bond_dev->features |= NETIF_F_VLAN_CHALLENGED;
} else {
@@ -1686,6 +1696,7 @@ int bond_release(struct net_device *bond
"left bond %s. VLAN blocking is removed\n",
bond_dev->name, slave_dev->name, bond_dev->name);
bond_dev->features &= ~NETIF_F_VLAN_CHALLENGED;
+#endif
}
write_unlock_bh(&bond->lock);
@@ -1693,7 +1704,9 @@ int bond_release(struct net_device *bond
/* must do this from outside any spinlocks */
bond_destroy_slave_symlinks(bond_dev, slave_dev);
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
bond_del_vlans_from_slave(bond, slave_dev);
+#endif
/* If the mode USES_PRIMARY, then we should only remove its
* promisc and mc settings if it was the curr_active_slave, but that was
@@ -1785,8 +1798,9 @@ static int bond_release_all(struct net_d
write_unlock_bh(&bond->lock);
bond_destroy_slave_symlinks(bond_dev, slave_dev);
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
bond_del_vlans_from_slave(bond, slave_dev);
-
+#endif
/* If the mode USES_PRIMARY, then we should only remove its
* promisc and mc settings if it was the curr_active_slave, but that was
* already taken care of above when we detached the slave
@@ -1835,6 +1849,7 @@ static int bond_release_all(struct net_d
*/
memset(bond_dev->dev_addr, 0, bond_dev->addr_len);
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (list_empty(&bond->vlan_list)) {
bond_dev->features |= NETIF_F_VLAN_CHALLENGED;
} else {
@@ -1847,6 +1862,7 @@ static int bond_release_all(struct net_d
"HW address matches its VLANs'.\n",
bond_dev->name);
}
+#endif
printk(KERN_INFO DRV_NAME
": %s: released all slaves\n",
@@ -2234,11 +2250,14 @@ out:
static int bond_has_ip(struct bonding *bond)
{
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
struct vlan_entry *vlan, *vlan_next;
+#endif
if (bond->master_ip)
return 1;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (list_empty(&bond->vlan_list))
return 0;
@@ -2247,6 +2266,7 @@ static int bond_has_ip(struct bonding *b
if (vlan->vlan_ip)
return 1;
}
+#endif
return 0;
}
@@ -2270,6 +2290,7 @@ static void bond_arp_send(struct net_dev
printk(KERN_ERR DRV_NAME ": ARP packet allocation failed\n");
return;
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (vlan_id) {
skb = vlan_put_tag(skb, vlan_id);
if (!skb) {
@@ -2277,30 +2298,38 @@ static void bond_arp_send(struct net_dev
return;
}
}
+#endif
arp_xmit(skb);
}
static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
{
- int i, vlan_id, rv;
+ int i;
u32 *targets = bond->params.arp_targets;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
+ int vlan_id, rv;
struct vlan_entry *vlan, *vlan_next;
struct net_device *vlan_dev;
struct flowi fl;
struct rtable *rt;
+#endif
for (i = 0; (i < BOND_MAX_ARP_TARGETS); i++) {
if (!targets[i])
continue;
dprintk("basa: target %x\n", targets[i]);
- if (list_empty(&bond->vlan_list)) {
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
+ if (list_empty(&bond->vlan_list))
+#endif
+ {
dprintk("basa: empty vlan: arp_send\n");
bond_arp_send(slave->dev, ARPOP_REQUEST, targets[i],
bond->master_ip, 0);
continue;
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
/*
* If VLANs are configured, we do a route lookup to
* determine which VLAN interface would be used, so we
@@ -2357,6 +2386,7 @@ static void bond_arp_send_all(struct bon
rt->u.dst.dev ? rt->u.dst.dev->name : "NULL");
}
ip_rt_put(rt);
+#endif
}
}
@@ -2367,9 +2397,10 @@ static void bond_arp_send_all(struct bon
static void bond_send_gratuitous_arp(struct bonding *bond)
{
struct slave *slave = bond->curr_active_slave;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
struct vlan_entry *vlan;
struct net_device *vlan_dev;
-
+#endif
dprintk("bond_send_grat_arp: bond %s slave %s\n", bond->dev->name,
slave ? slave->dev->name : "NULL");
if (!slave)
@@ -2380,6 +2411,7 @@ static void bond_send_gratuitous_arp(str
bond->master_ip, 0);
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
vlan_dev = bond->vlgrp->vlan_devices[vlan->vlan_id];
if (vlan->vlan_ip) {
@@ -2387,6 +2419,7 @@ static void bond_send_gratuitous_arp(str
vlan->vlan_ip, vlan->vlan_id);
}
}
+#endif
}
/*
@@ -3197,9 +3230,12 @@ static int bond_netdev_event(struct noti
static int bond_inetaddr_event(struct notifier_block *this, unsigned long event, void *ptr)
{
struct in_ifaddr *ifa = ptr;
- struct net_device *vlan_dev, *event_dev = ifa->ifa_dev->dev;
+ struct net_device *event_dev = ifa->ifa_dev->dev;
struct bonding *bond, *bond_next;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
struct vlan_entry *vlan, *vlan_next;
+ struct net_device *vlan_dev;
+#endif
list_for_each_entry_safe(bond, bond_next, &bond_dev_list, bond_list) {
if (bond->dev == event_dev) {
@@ -3215,6 +3251,7 @@ static int bond_inetaddr_event(struct no
}
}
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
if (list_empty(&bond->vlan_list))
continue;
@@ -3235,6 +3272,7 @@ static int bond_inetaddr_event(struct no
}
}
}
+#endif
}
return NOTIFY_DONE;
}
@@ -4120,7 +4158,9 @@ static int bond_init(struct net_device *
bond->current_arp_slave = NULL;
bond->primary_slave = NULL;
bond->dev = bond_dev;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
INIT_LIST_HEAD(&bond->vlan_list);
+#endif
/* Initialize the device entry points */
bond_dev->open = bond_open;
@@ -4151,6 +4191,7 @@ static int bond_init(struct net_device *
* transmitting */
bond_dev->features |= NETIF_F_LLTX;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
/* By default, we declare the bond to be fully
* VLAN hardware accelerated capable. Special
* care is taken in the various xmit functions
@@ -4163,6 +4204,7 @@ static int bond_init(struct net_device *
bond_dev->features |= (NETIF_F_HW_VLAN_TX |
NETIF_F_HW_VLAN_RX |
NETIF_F_HW_VLAN_FILTER);
+#endif
#ifdef CONFIG_PROC_FS
bond_create_proc_entry(bond);
diff -urpN linux-2.6.16.org/drivers/net/bonding/bonding.h linux-2.6.16.vlan/drivers/net/bonding/bonding.h
--- linux-2.6.16.org/drivers/net/bonding/bonding.h Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/drivers/net/bonding/bonding.h Tue Apr 11 10:15:58 2006
@@ -196,8 +196,10 @@ struct bonding {
struct ad_bond_info ad_info;
struct alb_bond_info alb_info;
struct bond_params params;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
struct list_head vlan_list;
struct vlan_group *vlgrp;
+#endif
};
/**
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] deinline a few large functions in vlan code - v3
2006-04-11 7:44 ` [PATCH 2/3] " Denis Vlasenko
@ 2006-04-11 7:47 ` Denis Vlasenko
2006-04-11 7:58 ` David S. Miller
0 siblings, 1 reply; 7+ messages in thread
From: Denis Vlasenko @ 2006-04-11 7:47 UTC (permalink / raw)
To: David S. Miller; +Cc: linux-kernel, linux-net, netdev
[-- Attachment #1: Type: text/plain, Size: 458 bytes --]
On Tuesday 11 April 2006 10:44, Denis Vlasenko wrote:
On Tuesday 11 April 2006 10:43, Denis Vlasenko wrote:
> These patches exclude VLAN code from netdevice drivers
> and from bonding module, and even remove vlan-related
> members of struct netdevice if VLAN is not configured.
>
> Compile tested on allyesconfig kernel with CONFIG_8021Q=y,m,n.
This one add #ifdefs around vlan_rx_* members of struct netdevice,
and moves large inlines out-of-line.
--
vda
[-- Attachment #2: 2.6.16.vlan_inline5_core.patch --]
[-- Type: text/x-diff, Size: 7579 bytes --]
diff -urpN linux-2.6.16.org/include/linux/if_vlan.h linux-2.6.16.vlan/include/linux/if_vlan.h
--- linux-2.6.16.org/include/linux/if_vlan.h Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/include/linux/if_vlan.h Tue Apr 11 10:15:59 2006
@@ -149,49 +149,9 @@ struct vlan_skb_tx_cookie {
#define vlan_tx_tag_get(__skb) (VLAN_TX_SKB_CB(__skb)->vlan_tag)
/* VLAN rx hw acceleration helper. This acts like netif_{rx,receive_skb}(). */
-static inline int __vlan_hwaccel_rx(struct sk_buff *skb,
+int __vlan_hwaccel_rx(struct sk_buff *skb,
struct vlan_group *grp,
- unsigned short vlan_tag, int polling)
-{
- struct net_device_stats *stats;
-
- skb->dev = grp->vlan_devices[vlan_tag & VLAN_VID_MASK];
- if (skb->dev == NULL) {
- dev_kfree_skb_any(skb);
-
- /* Not NET_RX_DROP, this is not being dropped
- * due to congestion.
- */
- return 0;
- }
-
- skb->dev->last_rx = jiffies;
-
- stats = vlan_dev_get_stats(skb->dev);
- stats->rx_packets++;
- stats->rx_bytes += skb->len;
-
- skb->priority = vlan_get_ingress_priority(skb->dev, vlan_tag);
- switch (skb->pkt_type) {
- case PACKET_BROADCAST:
- break;
-
- case PACKET_MULTICAST:
- stats->multicast++;
- break;
-
- case PACKET_OTHERHOST:
- /* Our lower layer thinks this is not local, let's make sure.
- * This allows the VLAN to have a different MAC than the underlying
- * device, and still route correctly.
- */
- if (!memcmp(eth_hdr(skb)->h_dest, skb->dev->dev_addr, ETH_ALEN))
- skb->pkt_type = PACKET_HOST;
- break;
- };
-
- return (polling ? netif_receive_skb(skb) : netif_rx(skb));
-}
+ unsigned short vlan_tag, int polling);
static inline int vlan_hwaccel_rx(struct sk_buff *skb,
struct vlan_group *grp,
@@ -218,43 +178,7 @@ static inline int vlan_hwaccel_receive_s
* Following the skb_unshare() example, in case of error, the calling function
* doesn't have to worry about freeing the original skb.
*/
-static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short tag)
-{
- struct vlan_ethhdr *veth;
-
- if (skb_headroom(skb) < VLAN_HLEN) {
- struct sk_buff *sk_tmp = skb;
- skb = skb_realloc_headroom(sk_tmp, VLAN_HLEN);
- kfree_skb(sk_tmp);
- if (!skb) {
- printk(KERN_ERR "vlan: failed to realloc headroom\n");
- return NULL;
- }
- } else {
- skb = skb_unshare(skb, GFP_ATOMIC);
- if (!skb) {
- printk(KERN_ERR "vlan: failed to unshare skbuff\n");
- return NULL;
- }
- }
-
- veth = (struct vlan_ethhdr *)skb_push(skb, VLAN_HLEN);
-
- /* Move the mac addresses to the beginning of the new header. */
- memmove(skb->data, skb->data + VLAN_HLEN, 2 * VLAN_ETH_ALEN);
-
- /* first, the ethernet type */
- veth->h_vlan_proto = __constant_htons(ETH_P_8021Q);
-
- /* now, the tag */
- veth->h_vlan_TCI = htons(tag);
-
- skb->protocol = __constant_htons(ETH_P_8021Q);
- skb->mac.raw -= VLAN_HLEN;
- skb->nh.raw -= VLAN_HLEN;
-
- return skb;
-}
+struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short tag);
/**
* __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting
diff -urpN linux-2.6.16.org/include/linux/netdevice.h linux-2.6.16.vlan/include/linux/netdevice.h
--- linux-2.6.16.org/include/linux/netdevice.h Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/include/linux/netdevice.h Tue Apr 11 10:15:59 2006
@@ -475,12 +475,14 @@ struct net_device
#define HAVE_TX_TIMEOUT
void (*tx_timeout) (struct net_device *dev);
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
void (*vlan_rx_register)(struct net_device *dev,
struct vlan_group *grp);
void (*vlan_rx_add_vid)(struct net_device *dev,
unsigned short vid);
void (*vlan_rx_kill_vid)(struct net_device *dev,
unsigned short vid);
+#endif
int (*hard_header_parse)(struct sk_buff *skb,
unsigned char *haddr);
diff -urpN linux-2.6.16.org/net/core/Makefile linux-2.6.16.vlan/net/core/Makefile
--- linux-2.6.16.org/net/core/Makefile Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/net/core/Makefile Tue Apr 11 10:15:59 2006
@@ -7,7 +7,7 @@ obj-y := sock.o request_sock.o skbuff.o
obj-$(CONFIG_SYSCTL) += sysctl_net_core.o
-obj-y += dev.o ethtool.o dev_mcast.o dst.o \
+obj-y += dev.o ethtool.o dev_mcast.o dev_vlan.o dst.o \
neighbour.o rtnetlink.o utils.o link_watch.o filter.o
obj-$(CONFIG_XFRM) += flow.o
diff -urpN linux-2.6.16.org/net/core/dev_vlan.c linux-2.6.16.vlan/net/core/dev_vlan.c
--- linux-2.6.16.org/net/core/dev_vlan.c Thu Jan 1 03:00:00 1970
+++ linux-2.6.16.vlan/net/core/dev_vlan.c Tue Apr 11 10:15:59 2006
@@ -0,0 +1,110 @@
+/* 802.1q helpers.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#if defined(CONFIG_VLAN_8021Q) || defined (CONFIG_VLAN_8021Q_MODULE)
+
+#include <linux/skbuff.h>
+#include <linux/if_vlan.h>
+
+/* VLAN rx hw acceleration helper. This acts like netif_{rx,receive_skb}(). */
+int __vlan_hwaccel_rx(struct sk_buff *skb,
+ struct vlan_group *grp,
+ unsigned short vlan_tag, int polling)
+{
+ struct net_device_stats *stats;
+
+ skb->dev = grp->vlan_devices[vlan_tag & VLAN_VID_MASK];
+ if (skb->dev == NULL) {
+ dev_kfree_skb_any(skb);
+
+ /* Not NET_RX_DROP, this is not being dropped
+ * due to congestion.
+ */
+ return 0;
+ }
+
+ skb->dev->last_rx = jiffies;
+
+ stats = vlan_dev_get_stats(skb->dev);
+ stats->rx_packets++;
+ stats->rx_bytes += skb->len;
+
+ skb->priority = vlan_get_ingress_priority(skb->dev, vlan_tag);
+ switch (skb->pkt_type) {
+ case PACKET_BROADCAST:
+ break;
+
+ case PACKET_MULTICAST:
+ stats->multicast++;
+ break;
+
+ case PACKET_OTHERHOST:
+ /* Our lower layer thinks this is not local, let's make sure.
+ * This allows the VLAN to have a different MAC than the underlying
+ * device, and still route correctly.
+ */
+ if (!memcmp(eth_hdr(skb)->h_dest, skb->dev->dev_addr, ETH_ALEN))
+ skb->pkt_type = PACKET_HOST;
+ break;
+ };
+
+ return (polling ? netif_receive_skb(skb) : netif_rx(skb));
+}
+EXPORT_SYMBOL(__vlan_hwaccel_rx);
+
+/**
+ * __vlan_put_tag - regular VLAN tag inserting
+ * @skb: skbuff to tag
+ * @tag: VLAN tag to insert
+ *
+ * Inserts the VLAN tag into @skb as part of the payload
+ * Returns a VLAN tagged skb. If a new skb is created, @skb is freed.
+ *
+ * Following the skb_unshare() example, in case of error, the calling function
+ * doesn't have to worry about freeing the original skb.
+ */
+struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short tag)
+{
+ struct vlan_ethhdr *veth;
+
+ if (skb_headroom(skb) < VLAN_HLEN) {
+ struct sk_buff *sk_tmp = skb;
+ skb = skb_realloc_headroom(sk_tmp, VLAN_HLEN);
+ kfree_skb(sk_tmp);
+ if (!skb) {
+ printk(KERN_ERR "vlan: failed to realloc headroom\n");
+ return NULL;
+ }
+ } else {
+ skb = skb_unshare(skb, GFP_ATOMIC);
+ if (!skb) {
+ printk(KERN_ERR "vlan: failed to unshare skbuff\n");
+ return NULL;
+ }
+ }
+
+ veth = (struct vlan_ethhdr *)skb_push(skb, VLAN_HLEN);
+
+ /* Move the mac addresses to the beginning of the new header. */
+ memmove(skb->data, skb->data + VLAN_HLEN, 2 * VLAN_ETH_ALEN);
+
+ /* first, the ethernet type */
+ veth->h_vlan_proto = __constant_htons(ETH_P_8021Q);
+
+ /* now, the tag */
+ veth->h_vlan_TCI = htons(tag);
+
+ skb->protocol = __constant_htons(ETH_P_8021Q);
+ skb->mac.raw -= VLAN_HLEN;
+ skb->nh.raw -= VLAN_HLEN;
+
+ return skb;
+}
+EXPORT_SYMBOL(__vlan_put_tag);
+
+#endif
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] deinline a few large functions in vlan code - v3
2006-04-11 7:47 ` [PATCH 3/3] " Denis Vlasenko
@ 2006-04-11 7:58 ` David S. Miller
2006-04-11 8:11 ` Denis Vlasenko
0 siblings, 1 reply; 7+ messages in thread
From: David S. Miller @ 2006-04-11 7:58 UTC (permalink / raw)
To: vda; +Cc: linux-kernel, linux-net, netdev
From: Denis Vlasenko <vda@ilport.com.ua>
Date: Tue, 11 Apr 2006 10:47:36 +0300
> On Tuesday 11 April 2006 10:44, Denis Vlasenko wrote:
> On Tuesday 11 April 2006 10:43, Denis Vlasenko wrote:
> > These patches exclude VLAN code from netdevice drivers
> > and from bonding module, and even remove vlan-related
> > members of struct netdevice if VLAN is not configured.
> >
> > Compile tested on allyesconfig kernel with CONFIG_8021Q=y,m,n.
>
> This one add #ifdefs around vlan_rx_* members of struct netdevice,
> and moves large inlines out-of-line.
This is not very nice, there is no way I'm applying these patches.
I think the current situation is far better than the large pile of
ifdefs these patches are adding to the tree.
Let's just leave things the way they are ok?
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] deinline a few large functions in vlan code - v3
2006-04-11 7:58 ` David S. Miller
@ 2006-04-11 8:11 ` Denis Vlasenko
2006-04-11 8:36 ` David S. Miller
0 siblings, 1 reply; 7+ messages in thread
From: Denis Vlasenko @ 2006-04-11 8:11 UTC (permalink / raw)
To: David S. Miller; +Cc: linux-kernel, linux-net, netdev
[-- Attachment #1: Type: text/plain, Size: 403 bytes --]
On Tuesday 11 April 2006 10:58, David S. Miller wrote:
> This is not very nice, there is no way I'm applying these patches.
>
> I think the current situation is far better than the large pile of
> ifdefs these patches are adding to the tree.
>
> Let's just leave things the way they are ok?
:(
Ok, one last try. Would you like this smallish patch instead?
It takes care of those BIG inlines.
--
vda
[-- Attachment #2: 2.6.16.vlan_inline5_core-1.patch --]
[-- Type: text/x-diff, Size: 6811 bytes --]
diff -urpN linux-2.6.16.org/net/core/Makefile linux-2.6.16.vlan/net/core/Makefile
--- linux-2.6.16.org/net/core/Makefile Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/net/core/Makefile Tue Apr 11 10:15:59 2006
@@ -7,7 +7,7 @@ obj-y := sock.o request_sock.o skbuff.o
obj-$(CONFIG_SYSCTL) += sysctl_net_core.o
-obj-y += dev.o ethtool.o dev_mcast.o dst.o \
+obj-y += dev.o ethtool.o dev_mcast.o dev_vlan.o dst.o \
neighbour.o rtnetlink.o utils.o link_watch.o filter.o
obj-$(CONFIG_XFRM) += flow.o
diff -urpN linux-2.6.16.org/include/linux/if_vlan.h linux-2.6.16.vlan/include/linux/if_vlan.h
--- linux-2.6.16.org/include/linux/if_vlan.h Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlan/include/linux/if_vlan.h Tue Apr 11 10:15:59 2006
@@ -149,49 +149,9 @@ struct vlan_skb_tx_cookie {
#define vlan_tx_tag_get(__skb) (VLAN_TX_SKB_CB(__skb)->vlan_tag)
/* VLAN rx hw acceleration helper. This acts like netif_{rx,receive_skb}(). */
-static inline int __vlan_hwaccel_rx(struct sk_buff *skb,
+int __vlan_hwaccel_rx(struct sk_buff *skb,
struct vlan_group *grp,
- unsigned short vlan_tag, int polling)
-{
- struct net_device_stats *stats;
-
- skb->dev = grp->vlan_devices[vlan_tag & VLAN_VID_MASK];
- if (skb->dev == NULL) {
- dev_kfree_skb_any(skb);
-
- /* Not NET_RX_DROP, this is not being dropped
- * due to congestion.
- */
- return 0;
- }
-
- skb->dev->last_rx = jiffies;
-
- stats = vlan_dev_get_stats(skb->dev);
- stats->rx_packets++;
- stats->rx_bytes += skb->len;
-
- skb->priority = vlan_get_ingress_priority(skb->dev, vlan_tag);
- switch (skb->pkt_type) {
- case PACKET_BROADCAST:
- break;
-
- case PACKET_MULTICAST:
- stats->multicast++;
- break;
-
- case PACKET_OTHERHOST:
- /* Our lower layer thinks this is not local, let's make sure.
- * This allows the VLAN to have a different MAC than the underlying
- * device, and still route correctly.
- */
- if (!memcmp(eth_hdr(skb)->h_dest, skb->dev->dev_addr, ETH_ALEN))
- skb->pkt_type = PACKET_HOST;
- break;
- };
-
- return (polling ? netif_receive_skb(skb) : netif_rx(skb));
-}
+ unsigned short vlan_tag, int polling);
static inline int vlan_hwaccel_rx(struct sk_buff *skb,
struct vlan_group *grp,
@@ -218,43 +178,7 @@ static inline int vlan_hwaccel_receive_s
* Following the skb_unshare() example, in case of error, the calling function
* doesn't have to worry about freeing the original skb.
*/
-static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short tag)
-{
- struct vlan_ethhdr *veth;
-
- if (skb_headroom(skb) < VLAN_HLEN) {
- struct sk_buff *sk_tmp = skb;
- skb = skb_realloc_headroom(sk_tmp, VLAN_HLEN);
- kfree_skb(sk_tmp);
- if (!skb) {
- printk(KERN_ERR "vlan: failed to realloc headroom\n");
- return NULL;
- }
- } else {
- skb = skb_unshare(skb, GFP_ATOMIC);
- if (!skb) {
- printk(KERN_ERR "vlan: failed to unshare skbuff\n");
- return NULL;
- }
- }
-
- veth = (struct vlan_ethhdr *)skb_push(skb, VLAN_HLEN);
-
- /* Move the mac addresses to the beginning of the new header. */
- memmove(skb->data, skb->data + VLAN_HLEN, 2 * VLAN_ETH_ALEN);
-
- /* first, the ethernet type */
- veth->h_vlan_proto = __constant_htons(ETH_P_8021Q);
-
- /* now, the tag */
- veth->h_vlan_TCI = htons(tag);
-
- skb->protocol = __constant_htons(ETH_P_8021Q);
- skb->mac.raw -= VLAN_HLEN;
- skb->nh.raw -= VLAN_HLEN;
-
- return skb;
-}
+struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short tag);
/**
* __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting
diff -urpN linux-2.6.16.org/net/core/dev_vlan.c linux-2.6.16.vlan/net/core/dev_vlan.c
--- linux-2.6.16.org/net/core/dev_vlan.c Thu Jan 1 03:00:00 1970
+++ linux-2.6.16.vlan/net/core/dev_vlan.c Tue Apr 11 10:15:59 2006
@@ -0,0 +1,110 @@
+/* 802.1q helpers.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+/* #if defined(CONFIG_VLAN_8021Q) || defined (CONFIG_VLAN_8021Q_MODULE) */
+
+#include <linux/skbuff.h>
+#include <linux/if_vlan.h>
+
+/* VLAN rx hw acceleration helper. This acts like netif_{rx,receive_skb}(). */
+int __vlan_hwaccel_rx(struct sk_buff *skb,
+ struct vlan_group *grp,
+ unsigned short vlan_tag, int polling)
+{
+ struct net_device_stats *stats;
+
+ skb->dev = grp->vlan_devices[vlan_tag & VLAN_VID_MASK];
+ if (skb->dev == NULL) {
+ dev_kfree_skb_any(skb);
+
+ /* Not NET_RX_DROP, this is not being dropped
+ * due to congestion.
+ */
+ return 0;
+ }
+
+ skb->dev->last_rx = jiffies;
+
+ stats = vlan_dev_get_stats(skb->dev);
+ stats->rx_packets++;
+ stats->rx_bytes += skb->len;
+
+ skb->priority = vlan_get_ingress_priority(skb->dev, vlan_tag);
+ switch (skb->pkt_type) {
+ case PACKET_BROADCAST:
+ break;
+
+ case PACKET_MULTICAST:
+ stats->multicast++;
+ break;
+
+ case PACKET_OTHERHOST:
+ /* Our lower layer thinks this is not local, let's make sure.
+ * This allows the VLAN to have a different MAC than the underlying
+ * device, and still route correctly.
+ */
+ if (!memcmp(eth_hdr(skb)->h_dest, skb->dev->dev_addr, ETH_ALEN))
+ skb->pkt_type = PACKET_HOST;
+ break;
+ };
+
+ return (polling ? netif_receive_skb(skb) : netif_rx(skb));
+}
+EXPORT_SYMBOL(__vlan_hwaccel_rx);
+
+/**
+ * __vlan_put_tag - regular VLAN tag inserting
+ * @skb: skbuff to tag
+ * @tag: VLAN tag to insert
+ *
+ * Inserts the VLAN tag into @skb as part of the payload
+ * Returns a VLAN tagged skb. If a new skb is created, @skb is freed.
+ *
+ * Following the skb_unshare() example, in case of error, the calling function
+ * doesn't have to worry about freeing the original skb.
+ */
+struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short tag)
+{
+ struct vlan_ethhdr *veth;
+
+ if (skb_headroom(skb) < VLAN_HLEN) {
+ struct sk_buff *sk_tmp = skb;
+ skb = skb_realloc_headroom(sk_tmp, VLAN_HLEN);
+ kfree_skb(sk_tmp);
+ if (!skb) {
+ printk(KERN_ERR "vlan: failed to realloc headroom\n");
+ return NULL;
+ }
+ } else {
+ skb = skb_unshare(skb, GFP_ATOMIC);
+ if (!skb) {
+ printk(KERN_ERR "vlan: failed to unshare skbuff\n");
+ return NULL;
+ }
+ }
+
+ veth = (struct vlan_ethhdr *)skb_push(skb, VLAN_HLEN);
+
+ /* Move the mac addresses to the beginning of the new header. */
+ memmove(skb->data, skb->data + VLAN_HLEN, 2 * VLAN_ETH_ALEN);
+
+ /* first, the ethernet type */
+ veth->h_vlan_proto = __constant_htons(ETH_P_8021Q);
+
+ /* now, the tag */
+ veth->h_vlan_TCI = htons(tag);
+
+ skb->protocol = __constant_htons(ETH_P_8021Q);
+ skb->mac.raw -= VLAN_HLEN;
+ skb->nh.raw -= VLAN_HLEN;
+
+ return skb;
+}
+EXPORT_SYMBOL(__vlan_put_tag);
+
+/* #endif */
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] deinline a few large functions in vlan code - v3
2006-04-11 8:11 ` Denis Vlasenko
@ 2006-04-11 8:36 ` David S. Miller
2006-04-11 12:24 ` Denis Vlasenko
0 siblings, 1 reply; 7+ messages in thread
From: David S. Miller @ 2006-04-11 8:36 UTC (permalink / raw)
To: vda; +Cc: linux-kernel, linux-net, netdev
From: Denis Vlasenko <vda@ilport.com.ua>
Date: Tue, 11 Apr 2006 11:11:12 +0300
> Ok, one last try. Would you like this smallish patch instead?
> It takes care of those BIG inlines.
You're putting vlan stuff into a net/core/*.c file, that
is not correct.
If we're not going to do the ifdef mess, fudging around it
by putting a "VLAN" function into generic networking core
code isn't the way to try and deal with it.
Like I said, let's just leave things they way they are.
Every suggestion shown so far has been worse than what we
have now.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] deinline a few large functions in vlan code - v3
2006-04-11 8:36 ` David S. Miller
@ 2006-04-11 12:24 ` Denis Vlasenko
0 siblings, 0 replies; 7+ messages in thread
From: Denis Vlasenko @ 2006-04-11 12:24 UTC (permalink / raw)
To: David S. Miller; +Cc: linux-kernel, linux-net, netdev
[-- Attachment #1: Type: text/plain, Size: 845 bytes --]
On Tuesday 11 April 2006 11:36, David S. Miller wrote:
> From: Denis Vlasenko <vda@ilport.com.ua>
> Date: Tue, 11 Apr 2006 11:11:12 +0300
>
> > Ok, one last try. Would you like this smallish patch instead?
> > It takes care of those BIG inlines.
>
> You're putting vlan stuff into a net/core/*.c file, that
> is not correct.
This code is _already_ there, duplicated in every driver
of VLAN-capable NIC.
In other words:
if you have just one VLAN-capable NIC driver compiled in,
you have that code in bzImage. If you have ten drivers,
you have that code duplicated ten times.
On my current kernel, I have several dozens NIC drivers
compiled in, because I don't want to mess with modules
on initrd for network boot...
Regarding net/core/*.c. You are right.
The below patch puts this code into net/8021q/if_vlan.c.
Does it look better?
--
vda
[-- Attachment #2: 2.6.16.vlan_inline6.patch --]
[-- Type: text/x-diff, Size: 7098 bytes --]
diff -urpN linux-2.6.16.org/include/linux/if_vlan.h linux-2.6.16.vlanmini/include/linux/if_vlan.h
--- linux-2.6.16.org/include/linux/if_vlan.h Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlanmini/include/linux/if_vlan.h Tue Apr 11 15:08:31 2006
@@ -149,49 +149,9 @@ struct vlan_skb_tx_cookie {
#define vlan_tx_tag_get(__skb) (VLAN_TX_SKB_CB(__skb)->vlan_tag)
/* VLAN rx hw acceleration helper. This acts like netif_{rx,receive_skb}(). */
-static inline int __vlan_hwaccel_rx(struct sk_buff *skb,
+int __vlan_hwaccel_rx(struct sk_buff *skb,
struct vlan_group *grp,
- unsigned short vlan_tag, int polling)
-{
- struct net_device_stats *stats;
-
- skb->dev = grp->vlan_devices[vlan_tag & VLAN_VID_MASK];
- if (skb->dev == NULL) {
- dev_kfree_skb_any(skb);
-
- /* Not NET_RX_DROP, this is not being dropped
- * due to congestion.
- */
- return 0;
- }
-
- skb->dev->last_rx = jiffies;
-
- stats = vlan_dev_get_stats(skb->dev);
- stats->rx_packets++;
- stats->rx_bytes += skb->len;
-
- skb->priority = vlan_get_ingress_priority(skb->dev, vlan_tag);
- switch (skb->pkt_type) {
- case PACKET_BROADCAST:
- break;
-
- case PACKET_MULTICAST:
- stats->multicast++;
- break;
-
- case PACKET_OTHERHOST:
- /* Our lower layer thinks this is not local, let's make sure.
- * This allows the VLAN to have a different MAC than the underlying
- * device, and still route correctly.
- */
- if (!memcmp(eth_hdr(skb)->h_dest, skb->dev->dev_addr, ETH_ALEN))
- skb->pkt_type = PACKET_HOST;
- break;
- };
-
- return (polling ? netif_receive_skb(skb) : netif_rx(skb));
-}
+ unsigned short vlan_tag, int polling);
static inline int vlan_hwaccel_rx(struct sk_buff *skb,
struct vlan_group *grp,
@@ -218,43 +178,7 @@ static inline int vlan_hwaccel_receive_s
* Following the skb_unshare() example, in case of error, the calling function
* doesn't have to worry about freeing the original skb.
*/
-static inline struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short tag)
-{
- struct vlan_ethhdr *veth;
-
- if (skb_headroom(skb) < VLAN_HLEN) {
- struct sk_buff *sk_tmp = skb;
- skb = skb_realloc_headroom(sk_tmp, VLAN_HLEN);
- kfree_skb(sk_tmp);
- if (!skb) {
- printk(KERN_ERR "vlan: failed to realloc headroom\n");
- return NULL;
- }
- } else {
- skb = skb_unshare(skb, GFP_ATOMIC);
- if (!skb) {
- printk(KERN_ERR "vlan: failed to unshare skbuff\n");
- return NULL;
- }
- }
-
- veth = (struct vlan_ethhdr *)skb_push(skb, VLAN_HLEN);
-
- /* Move the mac addresses to the beginning of the new header. */
- memmove(skb->data, skb->data + VLAN_HLEN, 2 * VLAN_ETH_ALEN);
-
- /* first, the ethernet type */
- veth->h_vlan_proto = __constant_htons(ETH_P_8021Q);
-
- /* now, the tag */
- veth->h_vlan_TCI = htons(tag);
-
- skb->protocol = __constant_htons(ETH_P_8021Q);
- skb->mac.raw -= VLAN_HLEN;
- skb->nh.raw -= VLAN_HLEN;
-
- return skb;
-}
+struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short tag);
/**
* __vlan_hwaccel_put_tag - hardware accelerated VLAN inserting
diff -urpN linux-2.6.16.org/net/8021q/Makefile linux-2.6.16.vlanmini/net/8021q/Makefile
--- linux-2.6.16.org/net/8021q/Makefile Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlanmini/net/8021q/Makefile Tue Apr 11 15:08:51 2006
@@ -2,6 +2,8 @@
# Makefile for the Linux VLAN layer.
#
+obj-y += if_vlan.o
+
obj-$(CONFIG_VLAN_8021Q) += 8021q.o
8021q-objs := vlan.o vlan_dev.o
diff -urpN linux-2.6.16.org/net/8021q/if_vlan.c linux-2.6.16.vlanmini/net/8021q/if_vlan.c
--- linux-2.6.16.org/net/8021q/if_vlan.c Thu Jan 1 03:00:00 1970
+++ linux-2.6.16.vlanmini/net/8021q/if_vlan.c Tue Apr 11 15:07:09 2006
@@ -0,0 +1,106 @@
+/* 802.1q helpers.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+
+#include <linux/skbuff.h>
+#include <linux/if_vlan.h>
+
+/* VLAN rx hw acceleration helper. This acts like netif_{rx,receive_skb}(). */
+int __vlan_hwaccel_rx(struct sk_buff *skb,
+ struct vlan_group *grp,
+ unsigned short vlan_tag, int polling)
+{
+ struct net_device_stats *stats;
+
+ skb->dev = grp->vlan_devices[vlan_tag & VLAN_VID_MASK];
+ if (skb->dev == NULL) {
+ dev_kfree_skb_any(skb);
+
+ /* Not NET_RX_DROP, this is not being dropped
+ * due to congestion.
+ */
+ return 0;
+ }
+
+ skb->dev->last_rx = jiffies;
+
+ stats = vlan_dev_get_stats(skb->dev);
+ stats->rx_packets++;
+ stats->rx_bytes += skb->len;
+
+ skb->priority = vlan_get_ingress_priority(skb->dev, vlan_tag);
+ switch (skb->pkt_type) {
+ case PACKET_BROADCAST:
+ break;
+
+ case PACKET_MULTICAST:
+ stats->multicast++;
+ break;
+
+ case PACKET_OTHERHOST:
+ /* Our lower layer thinks this is not local, let's make sure.
+ * This allows the VLAN to have a different MAC than the underlying
+ * device, and still route correctly.
+ */
+ if (!memcmp(eth_hdr(skb)->h_dest, skb->dev->dev_addr, ETH_ALEN))
+ skb->pkt_type = PACKET_HOST;
+ break;
+ };
+
+ return (polling ? netif_receive_skb(skb) : netif_rx(skb));
+}
+EXPORT_SYMBOL(__vlan_hwaccel_rx);
+
+/**
+ * __vlan_put_tag - regular VLAN tag inserting
+ * @skb: skbuff to tag
+ * @tag: VLAN tag to insert
+ *
+ * Inserts the VLAN tag into @skb as part of the payload
+ * Returns a VLAN tagged skb. If a new skb is created, @skb is freed.
+ *
+ * Following the skb_unshare() example, in case of error, the calling function
+ * doesn't have to worry about freeing the original skb.
+ */
+struct sk_buff *__vlan_put_tag(struct sk_buff *skb, unsigned short tag)
+{
+ struct vlan_ethhdr *veth;
+
+ if (skb_headroom(skb) < VLAN_HLEN) {
+ struct sk_buff *sk_tmp = skb;
+ skb = skb_realloc_headroom(sk_tmp, VLAN_HLEN);
+ kfree_skb(sk_tmp);
+ if (!skb) {
+ printk(KERN_ERR "vlan: failed to realloc headroom\n");
+ return NULL;
+ }
+ } else {
+ skb = skb_unshare(skb, GFP_ATOMIC);
+ if (!skb) {
+ printk(KERN_ERR "vlan: failed to unshare skbuff\n");
+ return NULL;
+ }
+ }
+
+ veth = (struct vlan_ethhdr *)skb_push(skb, VLAN_HLEN);
+
+ /* Move the mac addresses to the beginning of the new header. */
+ memmove(skb->data, skb->data + VLAN_HLEN, 2 * VLAN_ETH_ALEN);
+
+ /* first, the ethernet type */
+ veth->h_vlan_proto = __constant_htons(ETH_P_8021Q);
+
+ /* now, the tag */
+ veth->h_vlan_TCI = htons(tag);
+
+ skb->protocol = __constant_htons(ETH_P_8021Q);
+ skb->mac.raw -= VLAN_HLEN;
+ skb->nh.raw -= VLAN_HLEN;
+
+ return skb;
+}
+EXPORT_SYMBOL(__vlan_put_tag);
diff -urpN linux-2.6.16.org/net/Makefile linux-2.6.16.vlanmini/net/Makefile
--- linux-2.6.16.org/net/Makefile Mon Mar 20 07:53:29 2006
+++ linux-2.6.16.vlanmini/net/Makefile Tue Apr 11 15:05:11 2006
@@ -41,7 +41,7 @@ obj-$(CONFIG_RXRPC) += rxrpc/
obj-$(CONFIG_ATM) += atm/
obj-$(CONFIG_DECNET) += decnet/
obj-$(CONFIG_ECONET) += econet/
-obj-$(CONFIG_VLAN_8021Q) += 8021q/
+obj-y += 8021q/
obj-$(CONFIG_IP_DCCP) += dccp/
obj-$(CONFIG_IP_SCTP) += sctp/
obj-$(CONFIG_IEEE80211) += ieee80211/
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-04-11 12:24 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-11 7:43 [PATCH 1/3] deinline a few large functions in vlan code - v3 Denis Vlasenko
2006-04-11 7:44 ` [PATCH 2/3] " Denis Vlasenko
2006-04-11 7:47 ` [PATCH 3/3] " Denis Vlasenko
2006-04-11 7:58 ` David S. Miller
2006-04-11 8:11 ` Denis Vlasenko
2006-04-11 8:36 ` David S. Miller
2006-04-11 12:24 ` Denis Vlasenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).