netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: [PATCH 01/19] netdev: change transmit to limited range type
Date: Tue, 01 Sep 2009 09:39:47 +0200	[thread overview]
Message-ID: <4A9CCFC3.6020006@gmail.com> (raw)
In-Reply-To: <20090901055128.466779045@vyatta.com>

Stephen Hemminger a écrit :
> The transmit function should only return one of three possible values,
> some drivers got confused and returned errno's or other values.
> This changes the definition so that this can be caught at compile time.
> 
> Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
> 
> ---
> The patch will produce warnings until drivers are converted.
> 
> 
> ---
>  include/linux/netdevice.h |   22 +++++++++++++---------
>  1 file changed, 13 insertions(+), 9 deletions(-)
> 
> --- a/include/linux/netdevice.h	2009-08-31 16:47:58.703591891 -0700
> +++ b/include/linux/netdevice.h	2009-08-31 22:24:53.101472780 -0700
> @@ -79,17 +79,19 @@ struct wireless_dev;
>  #define net_xmit_eval(e)	((e) == NET_XMIT_CN? 0 : (e))
>  #define net_xmit_errno(e)	((e) != NET_XMIT_CN ? -ENOBUFS : 0)
>  
> +/* Driver transmit return codes */
> +enum netdev_tx {
> +	NETDEV_TX_OK = 0,	/* driver took care of packet */
> +	NETDEV_TX_BUSY,		/* driver tx path was busy*/
> +	NETDEV_TX_LOCKED = -1,	/* driver tx lock was already taken */
> +};
> +typedef enum netdev_tx netdev_tx_t;
> +
>  #endif
>  
>  #define MAX_ADDR_LEN	32		/* Largest hardware address length */
>  
> -/* Driver transmit return codes */
> -#define NETDEV_TX_OK 0		/* driver took care of packet */
> -#define NETDEV_TX_BUSY 1	/* driver tx path was busy*/
> -#define NETDEV_TX_LOCKED -1	/* driver tx lock was already taken */
> -
>  #ifdef  __KERNEL__
> -
>  /*
>   *	Compute the worst case header length according to the protocols
>   *	used.
> @@ -507,9 +509,11 @@ struct netdev_queue {
>   *     This function is called when network device transistions to the down
>   *     state.
>   *
> - * int (*ndo_start_xmit)(struct sk_buff *skb, struct net_device *dev);
> + * netdev_tx_t (*ndo_start_xmit)(struct sk_buff *skb,
> + *                               struct net_device *dev);
>   *	Called when a packet needs to be transmitted.
> - *	Must return NETDEV_TX_OK , NETDEV_TX_BUSY, or NETDEV_TX_LOCKED,
> + *	Must return NETDEV_TX_OK , NETDEV_TX_BUSY.
> + *        (can also return NETDEV_TX_LOCKED iff NETIF_F_LLTX)
>   *	Required can not be NULL.
>   *
>   * u16 (*ndo_select_queue)(struct net_device *dev, struct sk_buff *skb);
> @@ -580,7 +584,7 @@ struct net_device_ops {
>  	void			(*ndo_uninit)(struct net_device *dev);
>  	int			(*ndo_open)(struct net_device *dev);
>  	int			(*ndo_stop)(struct net_device *dev);
> -	int			(*ndo_start_xmit) (struct sk_buff *skb,
> +	netdev_tx_t		(*ndo_start_xmit) (struct sk_buff *skb,
>  						   struct net_device *dev);
>  	u16			(*ndo_select_queue)(struct net_device *dev,
>  						    struct sk_buff *skb);
> 

I was wondering if we could add a third parameter to 
ndo_start_xmit() (and pass the struct netdev_queue *txq)
in a smooth way, but could not find a solution.

Unconverted drivers would not care of this third param; but this
should be provided by callers (like dev_hard_start_xmit())

Most multiqueue drivers have to recompute it, and even monoqueue drivers
have to call netif_stop_queue(dev)/netif_queue_stopped(dev), all
using netdev_get_tx_queue(dev, 0) in the end...


  reply	other threads:[~2009-09-01  7:39 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-01  5:50 [PATCH 00/19] net_tx_t: network device transmit return value change Stephen Hemminger
2009-09-01  5:50 ` [PATCH 01/19] netdev: change transmit to limited range type Stephen Hemminger
2009-09-01  7:39   ` Eric Dumazet [this message]
2009-09-01  8:18     ` David Miller
2009-09-01  5:50 ` [PATCH 02/19] netdev: convert pseudo-devices to netdev_tx_t Stephen Hemminger
2009-09-01  5:50 ` [PATCH 03/19] convert ATM drivers " Stephen Hemminger
2009-09-01  5:50 ` [PATCH 04/19] convert hamradio drivers to netdev_txreturnt_t Stephen Hemminger
2009-09-01 15:30   ` Thomas Sailer
2009-09-01  5:50 ` [PATCH 05/19] isdn: convert to netdev_tx_t Stephen Hemminger
2009-09-01  5:50 ` [PATCH 06/19] usbnet: " Stephen Hemminger
2009-09-01  5:50 ` [PATCH 07/19] tokenring: " Stephen Hemminger
2009-09-01  5:50 ` [PATCH 08/19] wan: convert drivers " Stephen Hemminger
2009-09-01  5:50 ` [PATCH 09/19] hdlc: convert " Stephen Hemminger
2009-09-01  5:50 ` [PATCH 10/19] netdev: convert pcmcia drivers " Stephen Hemminger
2009-09-01  5:50 ` [PATCH 11/19] irda: convert " Stephen Hemminger
2009-09-01  5:50 ` [PATCH 12/19] netdev: convert pseudo drivers " Stephen Hemminger
2009-09-01  5:50 ` [PATCH 13/19] uwb: convert " Stephen Hemminger
     [not found]   ` <20090901055129.729527950-ZtmgI6mnKB3QT0dZR+AlfA@public.gmane.org>
2009-09-14 10:47     ` David Vrabel
2009-09-01  5:50 ` [PATCH 14/19] tulip: convert drivers " Stephen Hemminger
2009-09-02  5:48   ` Grant Grundler
2009-09-02  6:04     ` Stephen Hemminger
2009-09-02  6:08     ` Grant Grundler
2009-09-01  5:50 ` [PATCH 15/19] 3com: " Stephen Hemminger
2009-09-01  5:50 ` [PATCH 16/19] intel: " Stephen Hemminger
2009-09-02  1:03   ` Jeff Kirsher
2009-09-01  5:50 ` [PATCH 17/19] appletalk: " Stephen Hemminger
2009-09-01  5:50 ` [PATCH 18/19] wireless: " Stephen Hemminger
     [not found]   ` <20090901055130.266010870-ZtmgI6mnKB3QT0dZR+AlfA@public.gmane.org>
2009-09-01 13:18     ` John W. Linville
2009-09-01  5:50 ` [PATCH 19/19] netdev: convert bulk of " Stephen Hemminger
2009-09-01 16:21   ` David Dillow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4A9CCFC3.6020006@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).