Skip to content

Commit eb72f74

Browse files
Hariprasad Shenaidavem330
authored andcommitted
cxgb4: Handle clip return values
Add a warn message when clip table overflows. If clip table isn't allocated, return from cxgb4_clip_release() to avoid panic. Disable offload if clip isn't enabled in the hardware. Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 515123e commit eb72f74

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ int cxgb4_clip_get(const struct net_device *dev, const u32 *lip, u8 v6)
118118
ret = clip6_get_mbox(dev, (const struct in6_addr *)lip);
119119
if (ret) {
120120
write_unlock_bh(&ctbl->lock);
121+
dev_err(adap->pdev_dev,
122+
"CLIP FW cmd failed with error %d, "
123+
"Connections using %pI6c wont be "
124+
"offloaded",
125+
ret, ce->addr6.sin6_addr.s6_addr);
121126
return ret;
122127
}
123128
} else {
@@ -127,6 +132,9 @@ int cxgb4_clip_get(const struct net_device *dev, const u32 *lip, u8 v6)
127132
}
128133
} else {
129134
write_unlock_bh(&ctbl->lock);
135+
dev_info(adap->pdev_dev, "CLIP table overflow, "
136+
"Connections using %pI6c wont be offloaded",
137+
(void *)lip);
130138
return -ENOMEM;
131139
}
132140
write_unlock_bh(&ctbl->lock);
@@ -146,6 +154,9 @@ void cxgb4_clip_release(const struct net_device *dev, const u32 *lip, u8 v6)
146154
int hash;
147155
int ret = -1;
148156

157+
if (!ctbl)
158+
return;
159+
149160
hash = clip_addr_hash(ctbl, addr, v6);
150161

151162
read_lock_bh(&ctbl->lock);

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4865,15 +4865,25 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
48654865
}
48664866

48674867
#if IS_ENABLED(CONFIG_IPV6)
4868-
adapter->clipt = t4_init_clip_tbl(adapter->clipt_start,
4869-
adapter->clipt_end);
4870-
if (!adapter->clipt) {
4871-
/* We tolerate a lack of clip_table, giving up
4872-
* some functionality
4868+
if ((CHELSIO_CHIP_VERSION(adapter->params.chip) <= CHELSIO_T5) &&
4869+
(!(t4_read_reg(adapter, LE_DB_CONFIG_A) & ASLIPCOMPEN_F))) {
4870+
/* CLIP functionality is not present in hardware,
4871+
* hence disable all offload features
48734872
*/
48744873
dev_warn(&pdev->dev,
4875-
"could not allocate Clip table, continuing\n");
4874+
"CLIP not enabled in hardware, continuing\n");
48764875
adapter->params.offload = 0;
4876+
} else {
4877+
adapter->clipt = t4_init_clip_tbl(adapter->clipt_start,
4878+
adapter->clipt_end);
4879+
if (!adapter->clipt) {
4880+
/* We tolerate a lack of clip_table, giving up
4881+
* some functionality
4882+
*/
4883+
dev_warn(&pdev->dev,
4884+
"could not allocate Clip table, continuing\n");
4885+
adapter->params.offload = 0;
4886+
}
48774887
}
48784888
#endif
48794889
if (is_offload(adapter) && tid_init(&adapter->tids) < 0) {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2802,6 +2802,10 @@
28022802
#define HASHEN_V(x) ((x) << HASHEN_S)
28032803
#define HASHEN_F HASHEN_V(1U)
28042804

2805+
#define ASLIPCOMPEN_S 17
2806+
#define ASLIPCOMPEN_V(x) ((x) << ASLIPCOMPEN_S)
2807+
#define ASLIPCOMPEN_F ASLIPCOMPEN_V(1U)
2808+
28052809
#define REQQPARERR_S 16
28062810
#define REQQPARERR_V(x) ((x) << REQQPARERR_S)
28072811
#define REQQPARERR_F REQQPARERR_V(1U)

0 commit comments

Comments
 (0)