Commit ede2762d authored by Kirill Tkhai's avatar Kirill Tkhai Committed by David S. Miller
Browse files

net: Make NETDEV_XXX commands enum { }



This patch is preparation to drop NETDEV_UNREGISTER_FINAL.
Since the cmd is used in usnic_ib_netdev_event_to_string()
to get cmd name, after plain removing NETDEV_UNREGISTER_FINAL
from everywhere, we'd have holes in event2str[] in this
function.

Instead of that, let's make NETDEV_XXX commands names
available for everyone, and to define netdev_cmd_to_name()
in the way we won't have to shaffle names after their
numbers are changed.

Signed-off-by: default avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c2b72e8e
Loading
Loading
Loading
Loading
+1 −14
Original line number Original line Diff line number Diff line
@@ -97,20 +97,7 @@ void usnic_ib_log_vf(struct usnic_ib_vf *vf)
/* Start of netdev section */
/* Start of netdev section */
static inline const char *usnic_ib_netdev_event_to_string(unsigned long event)
static inline const char *usnic_ib_netdev_event_to_string(unsigned long event)
{
{
	const char *event2str[] = {"NETDEV_NONE", "NETDEV_UP", "NETDEV_DOWN",
	return netdev_cmd_to_name(event);
		"NETDEV_REBOOT", "NETDEV_CHANGE",
		"NETDEV_REGISTER", "NETDEV_UNREGISTER", "NETDEV_CHANGEMTU",
		"NETDEV_CHANGEADDR", "NETDEV_GOING_DOWN", "NETDEV_FEAT_CHANGE",
		"NETDEV_BONDING_FAILOVER", "NETDEV_PRE_UP",
		"NETDEV_PRE_TYPE_CHANGE", "NETDEV_POST_TYPE_CHANGE",
		"NETDEV_POST_INT", "NETDEV_UNREGISTER_FINAL", "NETDEV_RELEASE",
		"NETDEV_NOTIFY_PEERS", "NETDEV_JOIN"
	};

	if (event >= ARRAY_SIZE(event2str))
		return "UNKNOWN_NETDEV_EVENT";
	else
		return event2str[event];
}
}


static void usnic_ib_qp_grp_modify_active_to_err(struct usnic_ib_dev *us_ibdev)
static void usnic_ib_qp_grp_modify_active_to_err(struct usnic_ib_dev *us_ibdev)
+36 −33
Original line number Original line Diff line number Diff line
@@ -2312,43 +2312,46 @@ struct netdev_lag_lower_state_info {


#include <linux/notifier.h>
#include <linux/notifier.h>


/* netdevice notifier chain. Please remember to update the rtnetlink
/* netdevice notifier chain. Please remember to update netdev_cmd_to_name()
 * notification exclusion list in rtnetlink_event() when adding new
 * and the rtnetlink notification exclusion list in rtnetlink_event() when
 * types.
 * adding new types.
 */
 */
#define NETDEV_UP	0x0001	/* For now you can't veto a device up/down */
enum netdev_cmd {
#define NETDEV_DOWN	0x0002
	NETDEV_UP	= 1,	/* For now you can't veto a device up/down */
#define NETDEV_REBOOT	0x0003	/* Tell a protocol stack a network interface
	NETDEV_DOWN,
	NETDEV_REBOOT,		/* Tell a protocol stack a network interface
				   detected a hardware crash and restarted
				   detected a hardware crash and restarted
				   - we can use this eg to kick tcp sessions
				   - we can use this eg to kick tcp sessions
				   once done */
				   once done */
#define NETDEV_CHANGE	0x0004	/* Notify device state change */
	NETDEV_CHANGE,		/* Notify device state change */
#define NETDEV_REGISTER 0x0005
	NETDEV_REGISTER,
#define NETDEV_UNREGISTER	0x0006
	NETDEV_UNREGISTER,
#define NETDEV_CHANGEMTU	0x0007 /* notify after mtu change happened */
	NETDEV_CHANGEMTU,	/* notify after mtu change happened */
#define NETDEV_CHANGEADDR	0x0008
	NETDEV_CHANGEADDR,
#define NETDEV_GOING_DOWN	0x0009
	NETDEV_GOING_DOWN,
#define NETDEV_CHANGENAME	0x000A
	NETDEV_CHANGENAME,
#define NETDEV_FEAT_CHANGE	0x000B
	NETDEV_FEAT_CHANGE,
#define NETDEV_BONDING_FAILOVER 0x000C
	NETDEV_BONDING_FAILOVER,
#define NETDEV_PRE_UP		0x000D
	NETDEV_PRE_UP,
#define NETDEV_PRE_TYPE_CHANGE	0x000E
	NETDEV_PRE_TYPE_CHANGE,
#define NETDEV_POST_TYPE_CHANGE	0x000F
	NETDEV_POST_TYPE_CHANGE,
#define NETDEV_POST_INIT	0x0010
	NETDEV_POST_INIT,
#define NETDEV_UNREGISTER_FINAL 0x0011
	NETDEV_UNREGISTER_FINAL,
#define NETDEV_RELEASE		0x0012
	NETDEV_RELEASE,
#define NETDEV_NOTIFY_PEERS	0x0013
	NETDEV_NOTIFY_PEERS,
#define NETDEV_JOIN		0x0014
	NETDEV_JOIN,
#define NETDEV_CHANGEUPPER	0x0015
	NETDEV_CHANGEUPPER,
#define NETDEV_RESEND_IGMP	0x0016
	NETDEV_RESEND_IGMP,
#define NETDEV_PRECHANGEMTU	0x0017 /* notify before mtu change happened */
	NETDEV_PRECHANGEMTU,	/* notify before mtu change happened */
#define NETDEV_CHANGEINFODATA	0x0018
	NETDEV_CHANGEINFODATA,
#define NETDEV_BONDING_INFO	0x0019
	NETDEV_BONDING_INFO,
#define NETDEV_PRECHANGEUPPER	0x001A
	NETDEV_PRECHANGEUPPER,
#define NETDEV_CHANGELOWERSTATE	0x001B
	NETDEV_CHANGELOWERSTATE,
#define NETDEV_UDP_TUNNEL_PUSH_INFO	0x001C
	NETDEV_UDP_TUNNEL_PUSH_INFO,
#define NETDEV_UDP_TUNNEL_DROP_INFO	0x001D
	NETDEV_UDP_TUNNEL_DROP_INFO,
#define NETDEV_CHANGE_TX_QUEUE_LEN	0x001E
	NETDEV_CHANGE_TX_QUEUE_LEN,
};
const char *netdev_cmd_to_name(enum netdev_cmd cmd);


int register_netdevice_notifier(struct notifier_block *nb);
int register_netdevice_notifier(struct notifier_block *nb);
int unregister_netdevice_notifier(struct notifier_block *nb);
int unregister_netdevice_notifier(struct notifier_block *nb);
+20 −0
Original line number Original line Diff line number Diff line
@@ -1571,6 +1571,26 @@ static void dev_disable_gro_hw(struct net_device *dev)
		netdev_WARN(dev, "failed to disable GRO_HW!\n");
		netdev_WARN(dev, "failed to disable GRO_HW!\n");
}
}


const char *netdev_cmd_to_name(enum netdev_cmd cmd)
{
#define N(val) 						\
	case NETDEV_##val:				\
		return "NETDEV_" __stringify(val);
	switch (cmd) {
	N(UP) N(DOWN) N(REBOOT) N(CHANGE) N(REGISTER) N(UNREGISTER)
	N(CHANGEMTU) N(CHANGEADDR) N(GOING_DOWN) N(CHANGENAME) N(FEAT_CHANGE)
	N(BONDING_FAILOVER) N(PRE_UP) N(PRE_TYPE_CHANGE) N(POST_TYPE_CHANGE)
	N(POST_INIT) N(RELEASE) N(NOTIFY_PEERS) N(JOIN) N(CHANGEUPPER)
	N(RESEND_IGMP) N(PRECHANGEMTU) N(CHANGEINFODATA) N(BONDING_INFO)
	N(PRECHANGEUPPER) N(CHANGELOWERSTATE) N(UDP_TUNNEL_PUSH_INFO)
	N(UDP_TUNNEL_DROP_INFO) N(CHANGE_TX_QUEUE_LEN)
	N(UNREGISTER_FINAL)
	};
#undef N
	return "UNKNOWN_NETDEV_EVENT";
}
EXPORT_SYMBOL_GPL(netdev_cmd_to_name);

static int call_netdevice_notifier(struct notifier_block *nb, unsigned long val,
static int call_netdevice_notifier(struct notifier_block *nb, unsigned long val,
				   struct net_device *dev)
				   struct net_device *dev)
{
{