Skip to content

Commit 1dec4ce

Browse files
Ganesh Goudardavem330
authored andcommitted
cxgb4: Fix tids count for ipv6 offload connection
the adapter consumes two tids for every ipv6 offload connection be it active or passive, calculate tid usage count accordingly. Also change the signatures of relevant functions to get the address family. Signed-off-by: Rizwan Ansari <[email protected]> Signed-off-by: Varun Prakash <[email protected]> Signed-off-by: Ganesh Goudar <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e5c5180 commit 1dec4ce

File tree

6 files changed

+71
-31
lines changed

6 files changed

+71
-31
lines changed

drivers/infiniband/hw/cxgb4/cm.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,8 @@ void _c4iw_free_ep(struct kref *kref)
398398
(const u32 *)&sin6->sin6_addr.s6_addr,
399399
1);
400400
}
401-
cxgb4_remove_tid(ep->com.dev->rdev.lldi.tids, 0, ep->hwtid);
401+
cxgb4_remove_tid(ep->com.dev->rdev.lldi.tids, 0, ep->hwtid,
402+
ep->com.local_addr.ss_family);
402403
dst_release(ep->dst);
403404
cxgb4_l2t_release(ep->l2t);
404405
if (ep->mpa_skb)
@@ -1199,7 +1200,7 @@ static int act_establish(struct c4iw_dev *dev, struct sk_buff *skb)
11991200

12001201
/* setup the hwtid for this connection */
12011202
ep->hwtid = tid;
1202-
cxgb4_insert_tid(t, ep, tid);
1203+
cxgb4_insert_tid(t, ep, tid, ep->com.local_addr.ss_family);
12031204
insert_ep_tid(ep);
12041205

12051206
ep->snd_seq = be32_to_cpu(req->snd_isn);
@@ -2304,7 +2305,8 @@ static int act_open_rpl(struct c4iw_dev *dev, struct sk_buff *skb)
23042305
(const u32 *)&sin6->sin6_addr.s6_addr, 1);
23052306
}
23062307
if (status && act_open_has_tid(status))
2307-
cxgb4_remove_tid(ep->com.dev->rdev.lldi.tids, 0, GET_TID(rpl));
2308+
cxgb4_remove_tid(ep->com.dev->rdev.lldi.tids, 0, GET_TID(rpl),
2309+
ep->com.local_addr.ss_family);
23082310

23092311
remove_handle(ep->com.dev, &ep->com.dev->atid_idr, atid);
23102312
cxgb4_free_atid(t, atid);
@@ -2581,7 +2583,8 @@ static int pass_accept_req(struct c4iw_dev *dev, struct sk_buff *skb)
25812583
child_ep->tx_chan, child_ep->smac_idx, child_ep->rss_qid);
25822584

25832585
init_timer(&child_ep->timer);
2584-
cxgb4_insert_tid(t, child_ep, hwtid);
2586+
cxgb4_insert_tid(t, child_ep, hwtid,
2587+
child_ep->com.local_addr.ss_family);
25852588
insert_ep_tid(child_ep);
25862589
if (accept_cr(child_ep, skb, req)) {
25872590
c4iw_put_ep(&parent_ep->com);
@@ -2849,7 +2852,8 @@ static int peer_abort(struct c4iw_dev *dev, struct sk_buff *skb)
28492852
1);
28502853
}
28512854
remove_handle(ep->com.dev, &ep->com.dev->hwtid_idr, ep->hwtid);
2852-
cxgb4_remove_tid(ep->com.dev->rdev.lldi.tids, 0, ep->hwtid);
2855+
cxgb4_remove_tid(ep->com.dev->rdev.lldi.tids, 0, ep->hwtid,
2856+
ep->com.local_addr.ss_family);
28532857
dst_release(ep->dst);
28542858
cxgb4_l2t_release(ep->l2t);
28552859
c4iw_reconnect(ep);

drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2669,6 +2669,8 @@ static int tid_info_show(struct seq_file *seq, void *v)
26692669

26702670
if (t4_read_reg(adap, LE_DB_CONFIG_A) & HASHEN_F) {
26712671
unsigned int sb;
2672+
seq_printf(seq, "Connections in use: %u\n",
2673+
atomic_read(&t->conns_in_use));
26722674

26732675
if (chip <= CHELSIO_T5)
26742676
sb = t4_read_reg(adap, LE_DB_SERVER_INDEX_A) / 4;
@@ -2699,17 +2701,23 @@ static int tid_info_show(struct seq_file *seq, void *v)
26992701
atomic_read(&t->hash_tids_in_use));
27002702
}
27012703
} else if (t->ntids) {
2704+
seq_printf(seq, "Connections in use: %u\n",
2705+
atomic_read(&t->conns_in_use));
2706+
27022707
seq_printf(seq, "TID range: 0..%u", t->ntids - 1);
27032708
seq_printf(seq, ", in use: %u\n",
27042709
atomic_read(&t->tids_in_use));
27052710
}
27062711

27072712
if (t->nstids)
2708-
seq_printf(seq, "STID range: %u..%u, in use: %u\n",
2713+
seq_printf(seq, "STID range: %u..%u, in use-IPv4/IPv6: %u/%u\n",
27092714
(!t->stid_base &&
27102715
(chip <= CHELSIO_T5)) ?
27112716
t->stid_base + 1 : t->stid_base,
2712-
t->stid_base + t->nstids - 1, t->stids_in_use);
2717+
t->stid_base + t->nstids - 1,
2718+
t->stids_in_use - t->v6_stids_in_use,
2719+
t->v6_stids_in_use);
2720+
27132721
if (t->natids)
27142722
seq_printf(seq, "ATID range: 0..%u, in use: %u\n",
27152723
t->natids - 1, t->atids_in_use);

drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,10 +1093,12 @@ int cxgb4_alloc_stid(struct tid_info *t, int family, void *data)
10931093
* This is equivalent to 4 TIDs. With CLIP enabled it
10941094
* needs 2 TIDs.
10951095
*/
1096-
if (family == PF_INET)
1097-
t->stids_in_use++;
1098-
else
1096+
if (family == PF_INET6) {
10991097
t->stids_in_use += 2;
1098+
t->v6_stids_in_use += 2;
1099+
} else {
1100+
t->stids_in_use++;
1101+
}
11001102
}
11011103
spin_unlock_bh(&t->stid_lock);
11021104
return stid;
@@ -1150,13 +1152,16 @@ void cxgb4_free_stid(struct tid_info *t, unsigned int stid, int family)
11501152
bitmap_release_region(t->stid_bmap, stid, 1);
11511153
t->stid_tab[stid].data = NULL;
11521154
if (stid < t->nstids) {
1153-
if (family == PF_INET)
1154-
t->stids_in_use--;
1155-
else
1155+
if (family == PF_INET6) {
11561156
t->stids_in_use -= 2;
1157+
t->v6_stids_in_use -= 2;
1158+
} else {
1159+
t->stids_in_use--;
1160+
}
11571161
} else {
11581162
t->sftids_in_use--;
11591163
}
1164+
11601165
spin_unlock_bh(&t->stid_lock);
11611166
}
11621167
EXPORT_SYMBOL(cxgb4_free_stid);
@@ -1232,7 +1237,8 @@ static void process_tid_release_list(struct work_struct *work)
12321237
* Release a TID and inform HW. If we are unable to allocate the release
12331238
* message we defer to a work queue.
12341239
*/
1235-
void cxgb4_remove_tid(struct tid_info *t, unsigned int chan, unsigned int tid)
1240+
void cxgb4_remove_tid(struct tid_info *t, unsigned int chan, unsigned int tid,
1241+
unsigned short family)
12361242
{
12371243
struct sk_buff *skb;
12381244
struct adapter *adap = container_of(t, struct adapter, tids);
@@ -1241,10 +1247,18 @@ void cxgb4_remove_tid(struct tid_info *t, unsigned int chan, unsigned int tid)
12411247

12421248
if (t->tid_tab[tid]) {
12431249
t->tid_tab[tid] = NULL;
1244-
if (t->hash_base && (tid >= t->hash_base))
1245-
atomic_dec(&t->hash_tids_in_use);
1246-
else
1247-
atomic_dec(&t->tids_in_use);
1250+
atomic_dec(&t->conns_in_use);
1251+
if (t->hash_base && (tid >= t->hash_base)) {
1252+
if (family == AF_INET6)
1253+
atomic_sub(2, &t->hash_tids_in_use);
1254+
else
1255+
atomic_dec(&t->hash_tids_in_use);
1256+
} else {
1257+
if (family == AF_INET6)
1258+
atomic_sub(2, &t->tids_in_use);
1259+
else
1260+
atomic_dec(&t->tids_in_use);
1261+
}
12481262
}
12491263

12501264
skb = alloc_skb(sizeof(struct cpl_tid_release), GFP_ATOMIC);
@@ -1292,10 +1306,12 @@ static int tid_init(struct tid_info *t)
12921306
spin_lock_init(&t->ftid_lock);
12931307

12941308
t->stids_in_use = 0;
1309+
t->v6_stids_in_use = 0;
12951310
t->sftids_in_use = 0;
12961311
t->afree = NULL;
12971312
t->atids_in_use = 0;
12981313
atomic_set(&t->tids_in_use, 0);
1314+
atomic_set(&t->conns_in_use, 0);
12991315
atomic_set(&t->hash_tids_in_use, 0);
13001316

13011317
/* Setup the free list for atid_tab and clear the stid bitmap. */

drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,14 @@ struct tid_info {
123123

124124
spinlock_t stid_lock;
125125
unsigned int stids_in_use;
126+
unsigned int v6_stids_in_use;
126127
unsigned int sftids_in_use;
127128

128129
/* TIDs in the TCAM */
129130
atomic_t tids_in_use;
130131
/* TIDs in the HASH */
131132
atomic_t hash_tids_in_use;
133+
atomic_t conns_in_use;
132134
/* lock for setting/clearing filter bitmap */
133135
spinlock_t ftid_lock;
134136
};
@@ -157,22 +159,30 @@ static inline void *lookup_stid(const struct tid_info *t, unsigned int stid)
157159
}
158160

159161
static inline void cxgb4_insert_tid(struct tid_info *t, void *data,
160-
unsigned int tid)
162+
unsigned int tid, unsigned short family)
161163
{
162164
t->tid_tab[tid] = data;
163-
if (t->hash_base && (tid >= t->hash_base))
164-
atomic_inc(&t->hash_tids_in_use);
165-
else
166-
atomic_inc(&t->tids_in_use);
165+
if (t->hash_base && (tid >= t->hash_base)) {
166+
if (family == AF_INET6)
167+
atomic_add(2, &t->hash_tids_in_use);
168+
else
169+
atomic_inc(&t->hash_tids_in_use);
170+
} else {
171+
if (family == AF_INET6)
172+
atomic_add(2, &t->tids_in_use);
173+
else
174+
atomic_inc(&t->tids_in_use);
175+
}
176+
atomic_inc(&t->conns_in_use);
167177
}
168178

169179
int cxgb4_alloc_atid(struct tid_info *t, void *data);
170180
int cxgb4_alloc_stid(struct tid_info *t, int family, void *data);
171181
int cxgb4_alloc_sftid(struct tid_info *t, int family, void *data);
172182
void cxgb4_free_atid(struct tid_info *t, unsigned int atid);
173183
void cxgb4_free_stid(struct tid_info *t, unsigned int stid, int family);
174-
void cxgb4_remove_tid(struct tid_info *t, unsigned int qid, unsigned int tid);
175-
184+
void cxgb4_remove_tid(struct tid_info *t, unsigned int qid, unsigned int tid,
185+
unsigned short family);
176186
struct in6_addr;
177187

178188
int cxgb4_create_server(const struct net_device *dev, unsigned int stid,

drivers/scsi/cxgbi/cxgb4i/cxgb4i.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ static void do_act_establish(struct cxgbi_device *cdev, struct sk_buff *skb)
806806

807807
cxgbi_sock_get(csk);
808808
csk->tid = tid;
809-
cxgb4_insert_tid(lldi->tids, csk, tid);
809+
cxgb4_insert_tid(lldi->tids, csk, tid, csk->csk_family);
810810
cxgbi_sock_set_flag(csk, CTPF_HAS_TID);
811811

812812
free_atid(csk);
@@ -956,7 +956,8 @@ static void do_act_open_rpl(struct cxgbi_device *cdev, struct sk_buff *skb)
956956
if (status && status != CPL_ERR_TCAM_FULL &&
957957
status != CPL_ERR_CONN_EXIST &&
958958
status != CPL_ERR_ARP_MISS)
959-
cxgb4_remove_tid(lldi->tids, csk->port_id, GET_TID(rpl));
959+
cxgb4_remove_tid(lldi->tids, csk->port_id, GET_TID(rpl),
960+
csk->csk_family);
960961

961962
cxgbi_sock_get(csk);
962963
spin_lock_bh(&csk->lock);
@@ -1590,7 +1591,8 @@ static void release_offload_resources(struct cxgbi_sock *csk)
15901591
free_atid(csk);
15911592
else if (cxgbi_sock_flag(csk, CTPF_HAS_TID)) {
15921593
lldi = cxgbi_cdev_priv(csk->cdev);
1593-
cxgb4_remove_tid(lldi->tids, 0, csk->tid);
1594+
cxgb4_remove_tid(lldi->tids, 0, csk->tid,
1595+
csk->csk_family);
15941596
cxgbi_sock_clear_flag(csk, CTPF_HAS_TID);
15951597
cxgbi_sock_put(csk);
15961598
}

drivers/target/iscsi/cxgbit/cxgbit_cm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,8 @@ void _cxgbit_free_csk(struct kref *kref)
752752
&sin6->sin6_addr.s6_addr, 1);
753753
}
754754

755-
cxgb4_remove_tid(csk->com.cdev->lldi.tids, 0, csk->tid);
755+
cxgb4_remove_tid(csk->com.cdev->lldi.tids, 0, csk->tid,
756+
csk->com.local_addr.ss_family);
756757
dst_release(csk->dst);
757758
cxgb4_l2t_release(csk->l2t);
758759

@@ -1313,8 +1314,7 @@ cxgbit_pass_accept_req(struct cxgbit_device *cdev, struct sk_buff *skb)
13131314
spin_lock(&cdev->cskq.lock);
13141315
list_add_tail(&csk->list, &cdev->cskq.list);
13151316
spin_unlock(&cdev->cskq.lock);
1316-
1317-
cxgb4_insert_tid(t, csk, tid);
1317+
cxgb4_insert_tid(t, csk, tid, csk->com.local_addr.ss_family);
13181318
cxgbit_pass_accept_rpl(csk, req);
13191319
goto rel_skb;
13201320

0 commit comments

Comments
 (0)