0001
0002 #ifndef _SUNVNETCOMMON_H
0003 #define _SUNVNETCOMMON_H
0004
0005 #include <linux/interrupt.h>
0006
0007
0008
0009
0010 #define VNET_CLEAN_TIMEOUT ((HZ / 100) + 1)
0011
0012 #define VNET_MAXPACKET (65535ULL + ETH_HLEN + VLAN_HLEN)
0013 #define VNET_TX_RING_SIZE 512
0014 #define VNET_TX_WAKEUP_THRESH(dr) ((dr)->pending / 4)
0015
0016 #define VNET_MINTSO 2048
0017 #define VNET_MAXTSO 65535
0018
0019 #define VNET_MAX_MTU 65535
0020
0021
0022
0023
0024
0025 #define VNET_PACKET_SKIP 6
0026
0027 #define VNET_MAXCOOKIES (VNET_MAXPACKET / PAGE_SIZE + 1)
0028
0029 #define VNET_MAX_TXQS 16
0030
0031 struct vnet_tx_entry {
0032 struct sk_buff *skb;
0033 unsigned int ncookies;
0034 struct ldc_trans_cookie cookies[VNET_MAXCOOKIES];
0035 };
0036
0037 struct vnet;
0038
0039 struct vnet_port_stats {
0040
0041 u32 rx_bytes;
0042 u32 tx_bytes;
0043 u32 rx_packets;
0044 u32 tx_packets;
0045 u32 event_up;
0046 u32 event_reset;
0047 u32 q_placeholder;
0048 };
0049
0050 #define NUM_VNET_PORT_STATS (sizeof(struct vnet_port_stats) / sizeof(u32))
0051
0052
0053
0054
0055
0056
0057
0058 struct vnet_port {
0059 struct vio_driver_state vio;
0060
0061 struct vnet_port_stats stats;
0062
0063 struct hlist_node hash;
0064 u8 raddr[ETH_ALEN];
0065 unsigned switch_port:1;
0066 unsigned tso:1;
0067 unsigned vsw:1;
0068 unsigned __pad:13;
0069
0070 struct vnet *vp;
0071 struct net_device *dev;
0072
0073 struct vnet_tx_entry tx_bufs[VNET_TX_RING_SIZE];
0074
0075 struct list_head list;
0076
0077 u32 stop_rx_idx;
0078 bool stop_rx;
0079 bool start_cons;
0080
0081 struct timer_list clean_timer;
0082
0083 u64 rmtu;
0084 u16 tsolen;
0085
0086 struct napi_struct napi;
0087 u32 napi_stop_idx;
0088 bool napi_resume;
0089 int rx_event;
0090 u16 q_index;
0091 };
0092
0093 static inline struct vnet_port *to_vnet_port(struct vio_driver_state *vio)
0094 {
0095 return container_of(vio, struct vnet_port, vio);
0096 }
0097
0098 #define VNET_PORT_HASH_SIZE 16
0099 #define VNET_PORT_HASH_MASK (VNET_PORT_HASH_SIZE - 1)
0100
0101 static inline unsigned int vnet_hashfn(u8 *mac)
0102 {
0103 unsigned int val = mac[4] ^ mac[5];
0104
0105 return val & (VNET_PORT_HASH_MASK);
0106 }
0107
0108 struct vnet_mcast_entry {
0109 u8 addr[ETH_ALEN];
0110 u8 sent;
0111 u8 hit;
0112 struct vnet_mcast_entry *next;
0113 };
0114
0115 struct vnet {
0116 spinlock_t lock;
0117 struct net_device *dev;
0118 u32 msg_enable;
0119 u8 q_used[VNET_MAX_TXQS];
0120 struct list_head port_list;
0121 struct hlist_head port_hash[VNET_PORT_HASH_SIZE];
0122 struct vnet_mcast_entry *mcast_list;
0123 struct list_head list;
0124 u64 local_mac;
0125 int nports;
0126 };
0127
0128
0129 #define VNET_PORT_TO_NET_DEVICE(__port) \
0130 ((__port)->vsw ? (__port)->dev : (__port)->vp->dev)
0131
0132
0133 void sunvnet_clean_timer_expire_common(struct timer_list *t);
0134 int sunvnet_open_common(struct net_device *dev);
0135 int sunvnet_close_common(struct net_device *dev);
0136 void sunvnet_set_rx_mode_common(struct net_device *dev, struct vnet *vp);
0137 int sunvnet_set_mac_addr_common(struct net_device *dev, void *p);
0138 void sunvnet_tx_timeout_common(struct net_device *dev, unsigned int txqueue);
0139 netdev_tx_t
0140 sunvnet_start_xmit_common(struct sk_buff *skb, struct net_device *dev,
0141 struct vnet_port *(*vnet_tx_port)
0142 (struct sk_buff *, struct net_device *));
0143 #ifdef CONFIG_NET_POLL_CONTROLLER
0144 void sunvnet_poll_controller_common(struct net_device *dev, struct vnet *vp);
0145 #endif
0146 void sunvnet_event_common(void *arg, int event);
0147 int sunvnet_send_attr_common(struct vio_driver_state *vio);
0148 int sunvnet_handle_attr_common(struct vio_driver_state *vio, void *arg);
0149 void sunvnet_handshake_complete_common(struct vio_driver_state *vio);
0150 int sunvnet_poll_common(struct napi_struct *napi, int budget);
0151 void sunvnet_port_free_tx_bufs_common(struct vnet_port *port);
0152 void vnet_port_reset(struct vnet_port *port);
0153 bool sunvnet_port_is_up_common(struct vnet_port *vnet);
0154 void sunvnet_port_add_txq_common(struct vnet_port *port);
0155 void sunvnet_port_rm_txq_common(struct vnet_port *port);
0156
0157 #endif