aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/netdevice.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/netdevice.h')
-rw-r--r--include/linux/netdevice.h75
1 files changed, 75 insertions, 0 deletions
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index d971346b0340..371fa8839d51 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -75,6 +75,9 @@ struct wireless_dev;
75#define NET_RX_SUCCESS 0 /* keep 'em coming, baby */ 75#define NET_RX_SUCCESS 0 /* keep 'em coming, baby */
76#define NET_RX_DROP 1 /* packet dropped */ 76#define NET_RX_DROP 1 /* packet dropped */
77 77
78/* Initial net device group. All devices belong to group 0 by default. */
79#define INIT_NETDEV_GROUP 0
80
78/* 81/*
79 * Transmit return codes: transmit return codes originate from three different 82 * Transmit return codes: transmit return codes originate from three different
80 * namespaces: 83 * namespaces:
@@ -643,6 +646,14 @@ struct xps_dev_maps {
643 (nr_cpu_ids * sizeof(struct xps_map *))) 646 (nr_cpu_ids * sizeof(struct xps_map *)))
644#endif /* CONFIG_XPS */ 647#endif /* CONFIG_XPS */
645 648
649#define TC_MAX_QUEUE 16
650#define TC_BITMASK 15
651/* HW offloaded queuing disciplines txq count and offset maps */
652struct netdev_tc_txq {
653 u16 count;
654 u16 offset;
655};
656
646/* 657/*
647 * This structure defines the management hooks for network devices. 658 * This structure defines the management hooks for network devices.
648 * The following hooks can be defined; unless noted otherwise, they are 659 * The following hooks can be defined; unless noted otherwise, they are
@@ -753,6 +764,11 @@ struct xps_dev_maps {
753 * int (*ndo_set_vf_port)(struct net_device *dev, int vf, 764 * int (*ndo_set_vf_port)(struct net_device *dev, int vf,
754 * struct nlattr *port[]); 765 * struct nlattr *port[]);
755 * int (*ndo_get_vf_port)(struct net_device *dev, int vf, struct sk_buff *skb); 766 * int (*ndo_get_vf_port)(struct net_device *dev, int vf, struct sk_buff *skb);
767 * int (*ndo_setup_tc)(struct net_device *dev, u8 tc)
768 * Called to setup 'tc' number of traffic classes in the net device. This
769 * is always called from the stack with the rtnl lock held and netif tx
770 * queues stopped. This allows the netdevice to perform queue management
771 * safely.
756 */ 772 */
757#define HAVE_NET_DEVICE_OPS 773#define HAVE_NET_DEVICE_OPS
758struct net_device_ops { 774struct net_device_ops {
@@ -811,6 +827,7 @@ struct net_device_ops {
811 struct nlattr *port[]); 827 struct nlattr *port[]);
812 int (*ndo_get_vf_port)(struct net_device *dev, 828 int (*ndo_get_vf_port)(struct net_device *dev,
813 int vf, struct sk_buff *skb); 829 int vf, struct sk_buff *skb);
830 int (*ndo_setup_tc)(struct net_device *dev, u8 tc);
814#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) 831#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
815 int (*ndo_fcoe_enable)(struct net_device *dev); 832 int (*ndo_fcoe_enable)(struct net_device *dev);
816 int (*ndo_fcoe_disable)(struct net_device *dev); 833 int (*ndo_fcoe_disable)(struct net_device *dev);
@@ -1143,6 +1160,9 @@ struct net_device {
1143 /* Data Center Bridging netlink ops */ 1160 /* Data Center Bridging netlink ops */
1144 const struct dcbnl_rtnl_ops *dcbnl_ops; 1161 const struct dcbnl_rtnl_ops *dcbnl_ops;
1145#endif 1162#endif
1163 u8 num_tc;
1164 struct netdev_tc_txq tc_to_txq[TC_MAX_QUEUE];
1165 u8 prio_tc_map[TC_BITMASK + 1];
1146 1166
1147#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE) 1167#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
1148 /* max exchange id for FCoE LRO by ddp */ 1168 /* max exchange id for FCoE LRO by ddp */
@@ -1153,12 +1173,66 @@ struct net_device {
1153 1173
1154 /* phy device may attach itself for hardware timestamping */ 1174 /* phy device may attach itself for hardware timestamping */
1155 struct phy_device *phydev; 1175 struct phy_device *phydev;
1176
1177 /* group the device belongs to */
1178 int group;
1156}; 1179};
1157#define to_net_dev(d) container_of(d, struct net_device, dev) 1180#define to_net_dev(d) container_of(d, struct net_device, dev)
1158 1181
1159#define NETDEV_ALIGN 32 1182#define NETDEV_ALIGN 32
1160 1183
1161static inline 1184static inline
1185int netdev_get_prio_tc_map(const struct net_device *dev, u32 prio)
1186{
1187 return dev->prio_tc_map[prio & TC_BITMASK];
1188}
1189
1190static inline
1191int netdev_set_prio_tc_map(struct net_device *dev, u8 prio, u8 tc)
1192{
1193 if (tc >= dev->num_tc)
1194 return -EINVAL;
1195
1196 dev->prio_tc_map[prio & TC_BITMASK] = tc & TC_BITMASK;
1197 return 0;
1198}
1199
1200static inline
1201void netdev_reset_tc(struct net_device *dev)
1202{
1203 dev->num_tc = 0;
1204 memset(dev->tc_to_txq, 0, sizeof(dev->tc_to_txq));
1205 memset(dev->prio_tc_map, 0, sizeof(dev->prio_tc_map));
1206}
1207
1208static inline
1209int netdev_set_tc_queue(struct net_device *dev, u8 tc, u16 count, u16 offset)
1210{
1211 if (tc >= dev->num_tc)
1212 return -EINVAL;
1213
1214 dev->tc_to_txq[tc].count = count;
1215 dev->tc_to_txq[tc].offset = offset;
1216 return 0;
1217}
1218
1219static inline
1220int netdev_set_num_tc(struct net_device *dev, u8 num_tc)
1221{
1222 if (num_tc > TC_MAX_QUEUE)
1223 return -EINVAL;
1224
1225 dev->num_tc = num_tc;
1226 return 0;
1227}
1228
1229static inline
1230int netdev_get_num_tc(struct net_device *dev)
1231{
1232 return dev->num_tc;
1233}
1234
1235static inline
1162struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev, 1236struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev,
1163 unsigned int index) 1237 unsigned int index)
1164{ 1238{
@@ -1844,6 +1918,7 @@ extern int dev_set_alias(struct net_device *, const char *, size_t);
1844extern int dev_change_net_namespace(struct net_device *, 1918extern int dev_change_net_namespace(struct net_device *,
1845 struct net *, const char *); 1919 struct net *, const char *);
1846extern int dev_set_mtu(struct net_device *, int); 1920extern int dev_set_mtu(struct net_device *, int);
1921extern void dev_set_group(struct net_device *, int);
1847extern int dev_set_mac_address(struct net_device *, 1922extern int dev_set_mac_address(struct net_device *,
1848 struct sockaddr *); 1923 struct sockaddr *);
1849extern int dev_hard_start_xmit(struct sk_buff *skb, 1924extern int dev_hard_start_xmit(struct sk_buff *skb,