Skip to content

Commit 487042a

Browse files
Himanshu Madhanidavem330
authored andcommitted
qlcnic: Implement GET_LED_STATUS command for 82xx adapter.
o GET_LED_STATUS command will be used by driver to get current beacon state from 82xx adapter. o Refactored qlcnic_store_beacon() to split 8200 and 8300 specific calls. Signed-off-by: Himanshu Madhani <[email protected]> Signed-off-by: Shahed Shaikh <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 099907f commit 487042a

File tree

5 files changed

+98
-46
lines changed

5 files changed

+98
-46
lines changed

drivers/net/ethernet/qlogic/qlcnic/qlcnic.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,7 @@ struct qlcnic_mac_list_s {
815815
#define QLCNIC_FW_CAPABILITY_2_LRO_MAX_TCP_SEG BIT_2
816816
#define QLCNIC_FW_CAP2_HW_LRO_IPV6 BIT_3
817817
#define QLCNIC_FW_CAPABILITY_2_OCBB BIT_5
818+
#define QLCNIC_FW_CAPABILITY_2_BEACON BIT_7
818819

819820
/* module types */
820821
#define LINKEVENT_MODULE_NOT_PRESENT 1
@@ -912,6 +913,9 @@ struct qlcnic_ipaddr {
912913
#define QLCNIC_IS_TSO_CAPABLE(adapter) \
913914
((adapter)->ahw->capabilities & QLCNIC_FW_CAPABILITY_TSO)
914915

916+
#define QLCNIC_BEACON_EANBLE 0xC
917+
#define QLCNIC_BEACON_DISABLE 0xD
918+
915919
#define QLCNIC_DEF_NUM_STS_DESC_RINGS 4
916920
#define QLCNIC_MSIX_TBL_SPACE 8192
917921
#define QLCNIC_PCI_REG_MSIX_TBL 0x44
@@ -1543,6 +1547,7 @@ int qlcnic_set_default_offload_settings(struct qlcnic_adapter *);
15431547
int qlcnic_reset_npar_config(struct qlcnic_adapter *);
15441548
int qlcnic_set_eswitch_port_config(struct qlcnic_adapter *);
15451549
void qlcnic_add_lb_filter(struct qlcnic_adapter *, struct sk_buff *, int, u16);
1550+
int qlcnic_get_beacon_state(struct qlcnic_adapter *, u8 *);
15461551
int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter);
15471552
int qlcnic_read_mac_addr(struct qlcnic_adapter *);
15481553
int qlcnic_setup_netdev(struct qlcnic_adapter *, struct net_device *, int);

drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static const struct qlcnic_mailbox_metadata qlcnic_mbx_tbl[] = {
3737
{QLCNIC_CMD_TEMP_SIZE, 4, 4},
3838
{QLCNIC_CMD_GET_TEMP_HDR, 4, 1},
3939
{QLCNIC_CMD_SET_DRV_VER, 4, 1},
40+
{QLCNIC_CMD_GET_LED_STATUS, 4, 2},
4041
};
4142

4243
static inline u32 qlcnic_get_cmd_signature(struct qlcnic_hardware_context *ahw)

drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,6 +1503,21 @@ int qlcnic_82xx_config_led(struct qlcnic_adapter *adapter, u32 state, u32 rate)
15031503
return rv;
15041504
}
15051505

1506+
int qlcnic_get_beacon_state(struct qlcnic_adapter *adapter, u8 *h_state)
1507+
{
1508+
struct qlcnic_cmd_args cmd;
1509+
int err;
1510+
1511+
err = qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_GET_LED_STATUS);
1512+
if (!err) {
1513+
err = qlcnic_issue_cmd(adapter, &cmd);
1514+
if (!err)
1515+
*h_state = cmd.rsp.arg[1];
1516+
}
1517+
qlcnic_free_mbx_args(&cmd);
1518+
return err;
1519+
}
1520+
15061521
void qlcnic_82xx_get_func_no(struct qlcnic_adapter *adapter)
15071522
{
15081523
void __iomem *msix_base_addr;

drivers/net/ethernet/qlogic/qlcnic/qlcnic_hw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ enum qlcnic_regs {
8787
#define QLCNIC_CMD_CONFIG_VPORT 0x32
8888
#define QLCNIC_CMD_GET_MAC_STATS 0x37
8989
#define QLCNIC_CMD_SET_DRV_VER 0x38
90+
#define QLCNIC_CMD_GET_LED_STATUS 0x3C
9091
#define QLCNIC_CMD_CONFIGURE_RSS 0x41
9192
#define QLCNIC_CMD_CONFIG_INTR_COAL 0x43
9293
#define QLCNIC_CMD_CONFIGURE_LED 0x44

drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c

Lines changed: 76 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -114,57 +114,51 @@ static int qlcnic_validate_beacon(struct qlcnic_adapter *adapter, u16 beacon,
114114
return 0;
115115
}
116116

117-
static ssize_t qlcnic_store_beacon(struct device *dev,
118-
struct device_attribute *attr,
119-
const char *buf, size_t len)
117+
static int qlcnic_83xx_store_beacon(struct qlcnic_adapter *adapter,
118+
const char *buf, size_t len)
120119
{
121-
struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
122120
struct qlcnic_hardware_context *ahw = adapter->ahw;
123-
int err, max_sds_rings = adapter->max_sds_rings;
124-
u16 beacon;
125-
u8 b_state, b_rate;
126121
unsigned long h_beacon;
122+
int err;
127123

128-
if (adapter->ahw->op_mode == QLCNIC_NON_PRIV_FUNC) {
129-
dev_warn(dev,
130-
"LED test not supported in non privileged mode\n");
131-
return -EOPNOTSUPP;
132-
}
124+
if (test_bit(__QLCNIC_RESETTING, &adapter->state))
125+
return -EIO;
133126

134-
if (qlcnic_83xx_check(adapter) &&
135-
!test_bit(__QLCNIC_RESETTING, &adapter->state)) {
136-
if (kstrtoul(buf, 2, &h_beacon))
137-
return -EINVAL;
127+
if (kstrtoul(buf, 2, &h_beacon))
128+
return -EINVAL;
138129

139-
if (ahw->beacon_state == h_beacon)
140-
return len;
130+
if (ahw->beacon_state == h_beacon)
131+
return len;
141132

142-
rtnl_lock();
143-
if (!ahw->beacon_state) {
144-
if (test_and_set_bit(__QLCNIC_LED_ENABLE,
145-
&adapter->state)) {
146-
rtnl_unlock();
147-
return -EBUSY;
148-
}
149-
}
150-
if (h_beacon) {
151-
err = qlcnic_83xx_config_led(adapter, 1, h_beacon);
152-
if (err)
153-
goto beacon_err;
154-
} else {
155-
err = qlcnic_83xx_config_led(adapter, 0, !h_beacon);
156-
if (err)
157-
goto beacon_err;
133+
rtnl_lock();
134+
if (!ahw->beacon_state) {
135+
if (test_and_set_bit(__QLCNIC_LED_ENABLE, &adapter->state)) {
136+
rtnl_unlock();
137+
return -EBUSY;
158138
}
159-
/* set the current beacon state */
139+
}
140+
141+
if (h_beacon)
142+
err = qlcnic_83xx_config_led(adapter, 1, h_beacon);
143+
else
144+
err = qlcnic_83xx_config_led(adapter, 0, !h_beacon);
145+
if (!err)
160146
ahw->beacon_state = h_beacon;
161-
beacon_err:
162-
if (!ahw->beacon_state)
163-
clear_bit(__QLCNIC_LED_ENABLE, &adapter->state);
164147

165-
rtnl_unlock();
166-
return len;
167-
}
148+
if (!ahw->beacon_state)
149+
clear_bit(__QLCNIC_LED_ENABLE, &adapter->state);
150+
151+
rtnl_unlock();
152+
return len;
153+
}
154+
155+
static int qlcnic_82xx_store_beacon(struct qlcnic_adapter *adapter,
156+
const char *buf, size_t len)
157+
{
158+
struct qlcnic_hardware_context *ahw = adapter->ahw;
159+
int err, max_sds_rings = adapter->max_sds_rings;
160+
u16 beacon;
161+
u8 h_beacon_state, b_state, b_rate;
168162

169163
if (len != sizeof(u16))
170164
return QL_STATUS_INVALID_PARAM;
@@ -174,16 +168,29 @@ static ssize_t qlcnic_store_beacon(struct device *dev,
174168
if (err)
175169
return err;
176170

177-
if (adapter->ahw->beacon_state == b_state)
171+
if ((ahw->capabilities2 & QLCNIC_FW_CAPABILITY_2_BEACON)) {
172+
err = qlcnic_get_beacon_state(adapter, &h_beacon_state);
173+
if (!err) {
174+
dev_info(&adapter->pdev->dev,
175+
"Failed to get current beacon state\n");
176+
} else {
177+
if (h_beacon_state == QLCNIC_BEACON_DISABLE)
178+
ahw->beacon_state = 0;
179+
else if (h_beacon_state == QLCNIC_BEACON_EANBLE)
180+
ahw->beacon_state = 2;
181+
}
182+
}
183+
184+
if (ahw->beacon_state == b_state)
178185
return len;
179186

180187
rtnl_lock();
181-
182-
if (!adapter->ahw->beacon_state)
188+
if (!ahw->beacon_state) {
183189
if (test_and_set_bit(__QLCNIC_LED_ENABLE, &adapter->state)) {
184190
rtnl_unlock();
185191
return -EBUSY;
186192
}
193+
}
187194

188195
if (test_bit(__QLCNIC_RESETTING, &adapter->state)) {
189196
err = -EIO;
@@ -206,14 +213,37 @@ static ssize_t qlcnic_store_beacon(struct device *dev,
206213
if (test_and_clear_bit(__QLCNIC_DIAG_RES_ALLOC, &adapter->state))
207214
qlcnic_diag_free_res(adapter->netdev, max_sds_rings);
208215

209-
out:
210-
if (!adapter->ahw->beacon_state)
216+
out:
217+
if (!ahw->beacon_state)
211218
clear_bit(__QLCNIC_LED_ENABLE, &adapter->state);
212219
rtnl_unlock();
213220

214221
return err;
215222
}
216223

224+
static ssize_t qlcnic_store_beacon(struct device *dev,
225+
struct device_attribute *attr,
226+
const char *buf, size_t len)
227+
{
228+
struct qlcnic_adapter *adapter = dev_get_drvdata(dev);
229+
int err = 0;
230+
231+
if (adapter->ahw->op_mode == QLCNIC_NON_PRIV_FUNC) {
232+
dev_warn(dev,
233+
"LED test not supported in non privileged mode\n");
234+
return -EOPNOTSUPP;
235+
}
236+
237+
if (qlcnic_82xx_check(adapter))
238+
err = qlcnic_82xx_store_beacon(adapter, buf, len);
239+
else if (qlcnic_83xx_check(adapter))
240+
err = qlcnic_83xx_store_beacon(adapter, buf, len);
241+
else
242+
return -EIO;
243+
244+
return err;
245+
}
246+
217247
static ssize_t qlcnic_show_beacon(struct device *dev,
218248
struct device_attribute *attr, char *buf)
219249
{

0 commit comments

Comments
 (0)