net: introduce NAPI_POLL_WEIGHT

Some drivers use a too big NAPI poll weight.

This patch adds a NAPI_POLL_WEIGHT default value
and issues an error message if a driver attempts
to use a bigger weight.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Eric Dumazet 2013-03-05 15:57:22 +00:00 committed by David S. Miller
parent dd9f319d94
commit 82dc3c63c6
2 changed files with 8 additions and 0 deletions

View File

@ -1475,6 +1475,11 @@ static inline void *netdev_priv(const struct net_device *dev)
*/ */
#define SET_NETDEV_DEVTYPE(net, devtype) ((net)->dev.type = (devtype)) #define SET_NETDEV_DEVTYPE(net, devtype) ((net)->dev.type = (devtype))
/* Default NAPI poll() weight
* Device drivers are strongly advised to not use bigger value
*/
#define NAPI_POLL_WEIGHT 64
/** /**
* netif_napi_add - initialize a napi context * netif_napi_add - initialize a napi context
* @dev: network device * @dev: network device

View File

@ -4057,6 +4057,9 @@ void netif_napi_add(struct net_device *dev, struct napi_struct *napi,
napi->gro_list = NULL; napi->gro_list = NULL;
napi->skb = NULL; napi->skb = NULL;
napi->poll = poll; napi->poll = poll;
if (weight > NAPI_POLL_WEIGHT)
pr_err_once("netif_napi_add() called with weight %d on device %s\n",
weight, dev->name);
napi->weight = weight; napi->weight = weight;
list_add(&napi->dev_list, &dev->napi_list); list_add(&napi->dev_list, &dev->napi_list);
napi->dev = dev; napi->dev = dev;