xref: /OK3568_Linux_fs/kernel/drivers/net/ethernet/chelsio/cxgb4/clip_tbl.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  *  This file is part of the Chelsio T4 Ethernet driver for Linux.
3*4882a593Smuzhiyun  *  Copyright (C) 2003-2014 Chelsio Communications.  All rights reserved.
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  *  Written by Deepak (deepak.s@chelsio.com)
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  *  This program is distributed in the hope that it will be useful, but WITHOUT
8*4882a593Smuzhiyun  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9*4882a593Smuzhiyun  *  FITNESS FOR A PARTICULAR PURPOSE.  See the LICENSE file included in this
10*4882a593Smuzhiyun  *  release for licensing terms and conditions.
11*4882a593Smuzhiyun  */
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun #include <linux/refcount.h>
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun struct clip_entry {
16*4882a593Smuzhiyun 	spinlock_t lock;	/* Hold while modifying clip reference */
17*4882a593Smuzhiyun 	refcount_t refcnt;
18*4882a593Smuzhiyun 	struct list_head list;
19*4882a593Smuzhiyun 	union {
20*4882a593Smuzhiyun 		struct sockaddr_in addr;
21*4882a593Smuzhiyun 		struct sockaddr_in6 addr6;
22*4882a593Smuzhiyun 	};
23*4882a593Smuzhiyun };
24*4882a593Smuzhiyun 
25*4882a593Smuzhiyun struct clip_tbl {
26*4882a593Smuzhiyun 	unsigned int clipt_start;
27*4882a593Smuzhiyun 	unsigned int clipt_size;
28*4882a593Smuzhiyun 	rwlock_t lock;
29*4882a593Smuzhiyun 	atomic_t nfree;
30*4882a593Smuzhiyun 	struct list_head ce_free_head;
31*4882a593Smuzhiyun 	void *cl_list;
32*4882a593Smuzhiyun 	struct list_head hash_list[];
33*4882a593Smuzhiyun };
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun enum {
36*4882a593Smuzhiyun 	CLIPT_MIN_HASH_BUCKETS = 2,
37*4882a593Smuzhiyun };
38*4882a593Smuzhiyun 
39*4882a593Smuzhiyun struct clip_tbl *t4_init_clip_tbl(unsigned int clipt_start,
40*4882a593Smuzhiyun 				  unsigned int clipt_end);
41*4882a593Smuzhiyun int cxgb4_clip_get(const struct net_device *dev, const u32 *lip, u8 v6);
42*4882a593Smuzhiyun void cxgb4_clip_release(const struct net_device *dev, const u32 *lip, u8 v6);
43*4882a593Smuzhiyun int clip_tbl_show(struct seq_file *seq, void *v);
44*4882a593Smuzhiyun int cxgb4_update_root_dev_clip(struct net_device *dev);
45*4882a593Smuzhiyun void t4_cleanup_clip_tbl(struct adapter *adap);
46