Skip to content

Commit edd572d

Browse files
felix-caviumdavem330
authored andcommitted
liquidio: change octnic_ctrl_pkt to do synchronous soft commands
1. Change struct octnic_ctrl_pkt to support synchronous operation. 2. Change code which use structure octnic_ctrl_pkt to send sc's synchronously. Signed-off-by: Weilin Chang <[email protected]> Signed-off-by: Felix Manlunas <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6870957 commit edd572d

File tree

6 files changed

+98
-110
lines changed

6 files changed

+98
-110
lines changed

drivers/net/ethernet/cavium/liquidio/lio_core.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -198,14 +198,15 @@ int liquidio_set_feature(struct net_device *netdev, int cmd, u16 param1)
198198
nctrl.ncmd.s.cmd = cmd;
199199
nctrl.ncmd.s.param1 = param1;
200200
nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
201-
nctrl.wait_time = 100;
202201
nctrl.netpndev = (u64)netdev;
203202
nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
204203

205204
ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl);
206-
if (ret < 0) {
205+
if (ret) {
207206
dev_err(&oct->pci_dev->dev, "Feature change failed in core (ret: 0x%x)\n",
208207
ret);
208+
if (ret > 0)
209+
ret = -EIO;
209210
}
210211
return ret;
211212
}
@@ -285,15 +286,7 @@ void liquidio_link_ctrl_cmd_completion(void *nctrl_ptr)
285286
struct octeon_device *oct = lio->oct_dev;
286287
u8 *mac;
287288

288-
if (nctrl->completion && nctrl->response_code) {
289-
/* Signal whoever is interested that the response code from the
290-
* firmware has arrived.
291-
*/
292-
WRITE_ONCE(*nctrl->response_code, nctrl->status);
293-
complete(nctrl->completion);
294-
}
295-
296-
if (nctrl->status)
289+
if (nctrl->sc_status)
297290
return;
298291

299292
switch (nctrl->ncmd.s.cmd) {

drivers/net/ethernet/cavium/liquidio/lio_ethtool.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,11 @@ lio_send_queue_count_update(struct net_device *netdev, uint32_t num_queues)
472472
nctrl.ncmd.s.param1 = num_queues;
473473
nctrl.ncmd.s.param2 = num_queues;
474474
nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
475-
nctrl.wait_time = 100;
476475
nctrl.netpndev = (u64)netdev;
477476
nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
478477

479478
ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl);
480-
if (ret < 0) {
479+
if (ret) {
481480
dev_err(&oct->pci_dev->dev, "Failed to send Queue reset command (ret: 0x%x)\n",
482481
ret);
483482
return -1;
@@ -708,13 +707,13 @@ static int octnet_gpio_access(struct net_device *netdev, int addr, int val)
708707
nctrl.ncmd.s.param1 = addr;
709708
nctrl.ncmd.s.param2 = val;
710709
nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
711-
nctrl.wait_time = 100;
712710
nctrl.netpndev = (u64)netdev;
713711
nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
714712

715713
ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl);
716-
if (ret < 0) {
717-
dev_err(&oct->pci_dev->dev, "Failed to configure gpio value\n");
714+
if (ret) {
715+
dev_err(&oct->pci_dev->dev,
716+
"Failed to configure gpio value, ret=%d\n", ret);
718717
return -EINVAL;
719718
}
720719

@@ -734,13 +733,13 @@ static int octnet_id_active(struct net_device *netdev, int val)
734733
nctrl.ncmd.s.cmd = OCTNET_CMD_ID_ACTIVE;
735734
nctrl.ncmd.s.param1 = val;
736735
nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
737-
nctrl.wait_time = 100;
738736
nctrl.netpndev = (u64)netdev;
739737
nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
740738

741739
ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl);
742-
if (ret < 0) {
743-
dev_err(&oct->pci_dev->dev, "Failed to configure gpio value\n");
740+
if (ret) {
741+
dev_err(&oct->pci_dev->dev,
742+
"Failed to configure gpio value, ret=%d\n", ret);
744743
return -EINVAL;
745744
}
746745

@@ -1412,7 +1411,6 @@ lio_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause)
14121411
nctrl.ncmd.u64 = 0;
14131412
nctrl.ncmd.s.cmd = OCTNET_CMD_SET_FLOW_CTL;
14141413
nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
1415-
nctrl.wait_time = 100;
14161414
nctrl.netpndev = (u64)netdev;
14171415
nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
14181416

@@ -1433,8 +1431,9 @@ lio_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *pause)
14331431
}
14341432

14351433
ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl);
1436-
if (ret < 0) {
1437-
dev_err(&oct->pci_dev->dev, "Failed to set pause parameter\n");
1434+
if (ret) {
1435+
dev_err(&oct->pci_dev->dev,
1436+
"Failed to set pause parameter, ret=%d\n", ret);
14381437
return -EINVAL;
14391438
}
14401439

drivers/net/ethernet/cavium/liquidio/lio_main.c

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2039,10 +2039,9 @@ static void liquidio_set_mcast_list(struct net_device *netdev)
20392039
/* Apparently, any activity in this call from the kernel has to
20402040
* be atomic. So we won't wait for response.
20412041
*/
2042-
nctrl.wait_time = 0;
20432042

20442043
ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl);
2045-
if (ret < 0) {
2044+
if (ret) {
20462045
dev_err(&oct->pci_dev->dev, "DEVFLAGS change failed in core (ret: 0x%x)\n",
20472046
ret);
20482047
}
@@ -2071,8 +2070,6 @@ static int liquidio_set_mac(struct net_device *netdev, void *p)
20712070
nctrl.ncmd.s.more = 1;
20722071
nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
20732072
nctrl.netpndev = (u64)netdev;
2074-
nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
2075-
nctrl.wait_time = 100;
20762073

20772074
nctrl.udd[0] = 0;
20782075
/* The MAC Address is presented in network byte order. */
@@ -2083,6 +2080,14 @@ static int liquidio_set_mac(struct net_device *netdev, void *p)
20832080
dev_err(&oct->pci_dev->dev, "MAC Address change failed\n");
20842081
return -ENOMEM;
20852082
}
2083+
2084+
if (nctrl.sc_status) {
2085+
dev_err(&oct->pci_dev->dev,
2086+
"%s: MAC Address change failed. sc return=%x\n",
2087+
__func__, nctrl.sc_status);
2088+
return -EIO;
2089+
}
2090+
20862091
memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
20872092
memcpy(((u8 *)&lio->linfo.hw_addr) + 2, addr->sa_data, ETH_ALEN);
20882093

@@ -2623,14 +2628,15 @@ static int liquidio_vlan_rx_add_vid(struct net_device *netdev,
26232628
nctrl.ncmd.s.cmd = OCTNET_CMD_ADD_VLAN_FILTER;
26242629
nctrl.ncmd.s.param1 = vid;
26252630
nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
2626-
nctrl.wait_time = 100;
26272631
nctrl.netpndev = (u64)netdev;
26282632
nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
26292633

26302634
ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl);
2631-
if (ret < 0) {
2635+
if (ret) {
26322636
dev_err(&oct->pci_dev->dev, "Add VLAN filter failed in core (ret: 0x%x)\n",
26332637
ret);
2638+
if (ret > 0)
2639+
ret = -EIO;
26342640
}
26352641

26362642
return ret;
@@ -2651,14 +2657,15 @@ static int liquidio_vlan_rx_kill_vid(struct net_device *netdev,
26512657
nctrl.ncmd.s.cmd = OCTNET_CMD_DEL_VLAN_FILTER;
26522658
nctrl.ncmd.s.param1 = vid;
26532659
nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
2654-
nctrl.wait_time = 100;
26552660
nctrl.netpndev = (u64)netdev;
26562661
nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
26572662

26582663
ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl);
2659-
if (ret < 0) {
2664+
if (ret) {
26602665
dev_err(&oct->pci_dev->dev, "Del VLAN filter failed in core (ret: 0x%x)\n",
26612666
ret);
2667+
if (ret > 0)
2668+
ret = -EIO;
26622669
}
26632670
return ret;
26642671
}
@@ -2684,15 +2691,16 @@ static int liquidio_set_rxcsum_command(struct net_device *netdev, int command,
26842691
nctrl.ncmd.s.cmd = command;
26852692
nctrl.ncmd.s.param1 = rx_cmd;
26862693
nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
2687-
nctrl.wait_time = 100;
26882694
nctrl.netpndev = (u64)netdev;
26892695
nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
26902696

26912697
ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl);
2692-
if (ret < 0) {
2698+
if (ret) {
26932699
dev_err(&oct->pci_dev->dev,
26942700
"DEVFLAGS RXCSUM change failed in core(ret:0x%x)\n",
26952701
ret);
2702+
if (ret > 0)
2703+
ret = -EIO;
26962704
}
26972705
return ret;
26982706
}
@@ -2720,15 +2728,16 @@ static int liquidio_vxlan_port_command(struct net_device *netdev, int command,
27202728
nctrl.ncmd.s.more = vxlan_cmd_bit;
27212729
nctrl.ncmd.s.param1 = vxlan_port;
27222730
nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
2723-
nctrl.wait_time = 100;
27242731
nctrl.netpndev = (u64)netdev;
27252732
nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
27262733

27272734
ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl);
2728-
if (ret < 0) {
2735+
if (ret) {
27292736
dev_err(&oct->pci_dev->dev,
27302737
"VxLAN port add/delete failed in core (ret:0x%x)\n",
27312738
ret);
2739+
if (ret > 0)
2740+
ret = -EIO;
27322741
}
27332742
return ret;
27342743
}
@@ -2851,6 +2860,7 @@ static int __liquidio_set_vf_mac(struct net_device *netdev, int vfidx,
28512860
struct lio *lio = GET_LIO(netdev);
28522861
struct octeon_device *oct = lio->oct_dev;
28532862
struct octnic_ctrl_pkt nctrl;
2863+
int ret = 0;
28542864

28552865
if (!is_valid_ether_addr(mac))
28562866
return -EINVAL;
@@ -2864,22 +2874,25 @@ static int __liquidio_set_vf_mac(struct net_device *netdev, int vfidx,
28642874
nctrl.ncmd.s.cmd = OCTNET_CMD_CHANGE_MACADDR;
28652875
/* vfidx is 0 based, but vf_num (param1) is 1 based */
28662876
nctrl.ncmd.s.param1 = vfidx + 1;
2867-
nctrl.ncmd.s.param2 = (is_admin_assigned ? 1 : 0);
28682877
nctrl.ncmd.s.more = 1;
28692878
nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
28702879
nctrl.netpndev = (u64)netdev;
2871-
nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
2872-
nctrl.wait_time = LIO_CMD_WAIT_TM;
2880+
if (is_admin_assigned) {
2881+
nctrl.ncmd.s.param2 = true;
2882+
nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
2883+
}
28732884

28742885
nctrl.udd[0] = 0;
28752886
/* The MAC Address is presented in network byte order. */
28762887
ether_addr_copy((u8 *)&nctrl.udd[0] + 2, mac);
28772888

28782889
oct->sriov_info.vf_macaddr[vfidx] = nctrl.udd[0];
28792890

2880-
octnet_send_nic_ctrl_pkt(oct, &nctrl);
2891+
ret = octnet_send_nic_ctrl_pkt(oct, &nctrl);
2892+
if (ret > 0)
2893+
ret = -EIO;
28812894

2882-
return 0;
2895+
return ret;
28832896
}
28842897

28852898
static int liquidio_set_vf_mac(struct net_device *netdev, int vfidx, u8 *mac)
@@ -2905,6 +2918,7 @@ static int liquidio_set_vf_vlan(struct net_device *netdev, int vfidx,
29052918
struct octeon_device *oct = lio->oct_dev;
29062919
struct octnic_ctrl_pkt nctrl;
29072920
u16 vlantci;
2921+
int ret = 0;
29082922

29092923
if (vfidx < 0 || vfidx >= oct->sriov_info.num_vfs_alloced)
29102924
return -EINVAL;
@@ -2936,13 +2950,17 @@ static int liquidio_set_vf_vlan(struct net_device *netdev, int vfidx,
29362950
nctrl.ncmd.s.more = 0;
29372951
nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
29382952
nctrl.cb_fn = NULL;
2939-
nctrl.wait_time = LIO_CMD_WAIT_TM;
29402953

2941-
octnet_send_nic_ctrl_pkt(oct, &nctrl);
2954+
ret = octnet_send_nic_ctrl_pkt(oct, &nctrl);
2955+
if (ret) {
2956+
if (ret > 0)
2957+
ret = -EIO;
2958+
return ret;
2959+
}
29422960

29432961
oct->sriov_info.vf_vlantci[vfidx] = vlantci;
29442962

2945-
return 0;
2963+
return ret;
29462964
}
29472965

29482966
static int liquidio_get_vf_config(struct net_device *netdev, int vfidx,
@@ -3063,6 +3081,7 @@ static int liquidio_set_vf_link_state(struct net_device *netdev, int vfidx,
30633081
struct lio *lio = GET_LIO(netdev);
30643082
struct octeon_device *oct = lio->oct_dev;
30653083
struct octnic_ctrl_pkt nctrl;
3084+
int ret = 0;
30663085

30673086
if (vfidx < 0 || vfidx >= oct->sriov_info.num_vfs_alloced)
30683087
return -EINVAL;
@@ -3078,13 +3097,15 @@ static int liquidio_set_vf_link_state(struct net_device *netdev, int vfidx,
30783097
nctrl.ncmd.s.more = 0;
30793098
nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
30803099
nctrl.cb_fn = NULL;
3081-
nctrl.wait_time = LIO_CMD_WAIT_TM;
30823100

3083-
octnet_send_nic_ctrl_pkt(oct, &nctrl);
3101+
ret = octnet_send_nic_ctrl_pkt(oct, &nctrl);
30843102

3085-
oct->sriov_info.vf_linkstate[vfidx] = linkstate;
3103+
if (!ret)
3104+
oct->sriov_info.vf_linkstate[vfidx] = linkstate;
3105+
else if (ret > 0)
3106+
ret = -EIO;
30863107

3087-
return 0;
3108+
return ret;
30883109
}
30893110

30903111
static int

0 commit comments

Comments
 (0)