Linux Audio

Check our new training course

Loading...
v6.8
  1/* SPDX-License-Identifier: GPL-2.0 */
  2#ifndef _SUNVNETCOMMON_H
  3#define _SUNVNETCOMMON_H
  4
  5#include <linux/interrupt.h>
  6
  7/* length of time (or less) we expect pending descriptors to be marked
  8 * as VIO_DESC_DONE and skbs ready to be freed
  9 */
 10#define	VNET_CLEAN_TIMEOUT		((HZ / 100) + 1)
 11
 12#define VNET_MAXPACKET			(65535ULL + ETH_HLEN + VLAN_HLEN)
 13#define VNET_TX_RING_SIZE		512
 14#define VNET_TX_WAKEUP_THRESH(dr)	((dr)->pending / 4)
 15
 16#define	VNET_MINTSO	 2048	/* VIO protocol's minimum TSO len */
 17#define	VNET_MAXTSO	65535	/* VIO protocol's maximum TSO len */
 18
 19#define VNET_MAX_MTU	65535
 20
 21/* VNET packets are sent in buffers with the first 6 bytes skipped
 22 * so that after the ethernet header the IPv4/IPv6 headers are aligned
 23 * properly.
 24 */
 25#define VNET_PACKET_SKIP		6
 26
 27#define	VNET_MAXCOOKIES			(VNET_MAXPACKET / PAGE_SIZE + 1)
 28
 29#define	VNET_MAX_TXQS		16
 30
 31struct vnet_tx_entry {
 32	struct sk_buff		*skb;
 33	unsigned int		ncookies;
 34	struct ldc_trans_cookie	cookies[VNET_MAXCOOKIES];
 35};
 36
 37struct vnet;
 38
 39struct vnet_port_stats {
 40	/* keep them all the same size */
 41	u32 rx_bytes;
 42	u32 tx_bytes;
 43	u32 rx_packets;
 44	u32 tx_packets;
 45	u32 event_up;
 46	u32 event_reset;
 47	u32 q_placeholder;
 48};
 49
 50#define NUM_VNET_PORT_STATS  (sizeof(struct vnet_port_stats) / sizeof(u32))
 51
 52/* Structure to describe a vnet-port or vsw-port in the MD.
 53 * If the vsw bit is set, this structure represents a vswitch
 54 * port, and the net_device can be found from ->dev. If the
 55 * vsw bit is not set, the net_device is available from ->vp->dev.
 56 * See the VNET_PORT_TO_NET_DEVICE macro below.
 57 */
 58struct vnet_port {
 59	struct vio_driver_state	vio;
 60
 61	struct vnet_port_stats stats;
 62
 63	struct hlist_node	hash;
 64	u8			raddr[ETH_ALEN];
 65	unsigned		switch_port:1;
 66	unsigned		tso:1;
 67	unsigned		vsw:1;
 68	unsigned		__pad:13;
 69
 70	struct vnet		*vp;
 71	struct net_device	*dev;
 72
 73	struct vnet_tx_entry	tx_bufs[VNET_TX_RING_SIZE];
 74
 75	struct list_head	list;
 76
 77	u32			stop_rx_idx;
 78	bool			stop_rx;
 79	bool			start_cons;
 80
 81	struct timer_list	clean_timer;
 82
 83	u64			rmtu;
 84	u16			tsolen;
 85
 86	struct napi_struct	napi;
 87	u32			napi_stop_idx;
 88	bool			napi_resume;
 89	int			rx_event;
 90	u16			q_index;
 91};
 92
 93static inline struct vnet_port *to_vnet_port(struct vio_driver_state *vio)
 94{
 95	return container_of(vio, struct vnet_port, vio);
 96}
 97
 98#define VNET_PORT_HASH_SIZE	16
 99#define VNET_PORT_HASH_MASK	(VNET_PORT_HASH_SIZE - 1)
100
101static inline unsigned int vnet_hashfn(u8 *mac)
102{
103	unsigned int val = mac[4] ^ mac[5];
104
105	return val & (VNET_PORT_HASH_MASK);
106}
107
108struct vnet_mcast_entry {
109	u8			addr[ETH_ALEN];
110	u8			sent;
111	u8			hit;
112	struct vnet_mcast_entry	*next;
113};
114
115struct vnet {
116	spinlock_t		lock; /* Protects port_list and port_hash.  */
 
 
117	struct net_device	*dev;
 
118	u32			msg_enable;
119	u8			q_used[VNET_MAX_TXQS];
120	struct list_head	port_list;
 
121	struct hlist_head	port_hash[VNET_PORT_HASH_SIZE];
 
122	struct vnet_mcast_entry	*mcast_list;
 
123	struct list_head	list;
124	u64			local_mac;
 
125	int			nports;
126};
127
128/* Def used by common code to get the net_device from the proper location */
129#define VNET_PORT_TO_NET_DEVICE(__port) \
130	((__port)->vsw ? (__port)->dev : (__port)->vp->dev)
131
132/* Common funcs */
133void sunvnet_clean_timer_expire_common(struct timer_list *t);
134int sunvnet_open_common(struct net_device *dev);
135int sunvnet_close_common(struct net_device *dev);
136void sunvnet_set_rx_mode_common(struct net_device *dev, struct vnet *vp);
137int sunvnet_set_mac_addr_common(struct net_device *dev, void *p);
138void sunvnet_tx_timeout_common(struct net_device *dev, unsigned int txqueue);
139netdev_tx_t
140sunvnet_start_xmit_common(struct sk_buff *skb, struct net_device *dev,
141			  struct vnet_port *(*vnet_tx_port)
142			  (struct sk_buff *, struct net_device *));
143#ifdef CONFIG_NET_POLL_CONTROLLER
144void sunvnet_poll_controller_common(struct net_device *dev, struct vnet *vp);
145#endif
146void sunvnet_event_common(void *arg, int event);
147int sunvnet_send_attr_common(struct vio_driver_state *vio);
148int sunvnet_handle_attr_common(struct vio_driver_state *vio, void *arg);
149void sunvnet_handshake_complete_common(struct vio_driver_state *vio);
150int sunvnet_poll_common(struct napi_struct *napi, int budget);
151void sunvnet_port_free_tx_bufs_common(struct vnet_port *port);
152void vnet_port_reset(struct vnet_port *port);
153bool sunvnet_port_is_up_common(struct vnet_port *vnet);
154void sunvnet_port_add_txq_common(struct vnet_port *port);
155void sunvnet_port_rm_txq_common(struct vnet_port *port);
156
157#endif /* _SUNVNETCOMMON_H */
v4.6
 
  1#ifndef _SUNVNETCOMMON_H
  2#define _SUNVNETCOMMON_H
  3
  4#include <linux/interrupt.h>
  5
  6/* length of time (or less) we expect pending descriptors to be marked
  7 * as VIO_DESC_DONE and skbs ready to be freed
  8 */
  9#define	VNET_CLEAN_TIMEOUT		((HZ / 100) + 1)
 10
 11#define VNET_MAXPACKET			(65535ULL + ETH_HLEN + VLAN_HLEN)
 12#define VNET_TX_RING_SIZE		512
 13#define VNET_TX_WAKEUP_THRESH(dr)	((dr)->pending / 4)
 14
 15#define	VNET_MINTSO	 2048	/* VIO protocol's minimum TSO len */
 16#define	VNET_MAXTSO	65535	/* VIO protocol's maximum TSO len */
 17
 
 
 18/* VNET packets are sent in buffers with the first 6 bytes skipped
 19 * so that after the ethernet header the IPv4/IPv6 headers are aligned
 20 * properly.
 21 */
 22#define VNET_PACKET_SKIP		6
 23
 24#define	VNET_MAXCOOKIES			(VNET_MAXPACKET / PAGE_SIZE + 1)
 25
 26#define	VNET_MAX_TXQS		16
 27
 28struct vnet_tx_entry {
 29	struct sk_buff		*skb;
 30	unsigned int		ncookies;
 31	struct ldc_trans_cookie	cookies[VNET_MAXCOOKIES];
 32};
 33
 34struct vnet;
 35
 
 
 
 
 
 
 
 
 
 
 
 
 
 36/* Structure to describe a vnet-port or vsw-port in the MD.
 37 * If the vsw bit is set, this structure represents a vswitch
 38 * port, and the net_device can be found from ->dev. If the
 39 * vsw bit is not set, the net_device is available from ->vp->dev.
 40 * See the VNET_PORT_TO_NET_DEVICE macro below.
 41 */
 42struct vnet_port {
 43	struct vio_driver_state	vio;
 44
 
 
 45	struct hlist_node	hash;
 46	u8			raddr[ETH_ALEN];
 47	unsigned		switch_port:1;
 48	unsigned		tso:1;
 49	unsigned		vsw:1;
 50	unsigned		__pad:13;
 51
 52	struct vnet		*vp;
 53	struct net_device	*dev;
 54
 55	struct vnet_tx_entry	tx_bufs[VNET_TX_RING_SIZE];
 56
 57	struct list_head	list;
 58
 59	u32			stop_rx_idx;
 60	bool			stop_rx;
 61	bool			start_cons;
 62
 63	struct timer_list	clean_timer;
 64
 65	u64			rmtu;
 66	u16			tsolen;
 67
 68	struct napi_struct	napi;
 69	u32			napi_stop_idx;
 70	bool			napi_resume;
 71	int			rx_event;
 72	u16			q_index;
 73};
 74
 75static inline struct vnet_port *to_vnet_port(struct vio_driver_state *vio)
 76{
 77	return container_of(vio, struct vnet_port, vio);
 78}
 79
 80#define VNET_PORT_HASH_SIZE	16
 81#define VNET_PORT_HASH_MASK	(VNET_PORT_HASH_SIZE - 1)
 82
 83static inline unsigned int vnet_hashfn(u8 *mac)
 84{
 85	unsigned int val = mac[4] ^ mac[5];
 86
 87	return val & (VNET_PORT_HASH_MASK);
 88}
 89
 90struct vnet_mcast_entry {
 91	u8			addr[ETH_ALEN];
 92	u8			sent;
 93	u8			hit;
 94	struct vnet_mcast_entry	*next;
 95};
 96
 97struct vnet {
 98	/* Protects port_list and port_hash.  */
 99	spinlock_t		lock;
100
101	struct net_device	*dev;
102
103	u32			msg_enable;
104
105	struct list_head	port_list;
106
107	struct hlist_head	port_hash[VNET_PORT_HASH_SIZE];
108
109	struct vnet_mcast_entry	*mcast_list;
110
111	struct list_head	list;
112	u64			local_mac;
113
114	int			nports;
115};
116
117/* Def used by common code to get the net_device from the proper location */
118#define VNET_PORT_TO_NET_DEVICE(__port) \
119	((__port)->vsw ? (__port)->dev : (__port)->vp->dev)
120
121/* Common funcs */
122void sunvnet_clean_timer_expire_common(unsigned long port0);
123int sunvnet_open_common(struct net_device *dev);
124int sunvnet_close_common(struct net_device *dev);
125void sunvnet_set_rx_mode_common(struct net_device *dev, struct vnet *vp);
126int sunvnet_set_mac_addr_common(struct net_device *dev, void *p);
127void sunvnet_tx_timeout_common(struct net_device *dev);
128int sunvnet_change_mtu_common(struct net_device *dev, int new_mtu);
129int sunvnet_start_xmit_common(struct sk_buff *skb, struct net_device *dev,
130			   struct vnet_port *(*vnet_tx_port)
131			   (struct sk_buff *, struct net_device *));
132#ifdef CONFIG_NET_POLL_CONTROLLER
133void sunvnet_poll_controller_common(struct net_device *dev, struct vnet *vp);
134#endif
135void sunvnet_event_common(void *arg, int event);
136int sunvnet_send_attr_common(struct vio_driver_state *vio);
137int sunvnet_handle_attr_common(struct vio_driver_state *vio, void *arg);
138void sunvnet_handshake_complete_common(struct vio_driver_state *vio);
139int sunvnet_poll_common(struct napi_struct *napi, int budget);
140void sunvnet_port_free_tx_bufs_common(struct vnet_port *port);
 
141bool sunvnet_port_is_up_common(struct vnet_port *vnet);
142void sunvnet_port_add_txq_common(struct vnet_port *port);
143void sunvnet_port_rm_txq_common(struct vnet_port *port);
144
145#endif /* _SUNVNETCOMMON_H */