forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c
....@@ -25,20 +25,20 @@
2525 #include "octeon_nic.h"
2626 #include "octeon_main.h"
2727 #include "octeon_network.h"
28
-#include <net/switchdev.h>
2928 #include "lio_vf_rep.h"
30
-#include "octeon_network.h"
3129
3230 static int lio_vf_rep_open(struct net_device *ndev);
3331 static int lio_vf_rep_stop(struct net_device *ndev);
3432 static netdev_tx_t lio_vf_rep_pkt_xmit(struct sk_buff *skb,
3533 struct net_device *ndev);
36
-static void lio_vf_rep_tx_timeout(struct net_device *netdev);
34
+static void lio_vf_rep_tx_timeout(struct net_device *netdev, unsigned int txqueue);
3735 static int lio_vf_rep_phys_port_name(struct net_device *dev,
3836 char *buf, size_t len);
3937 static void lio_vf_rep_get_stats64(struct net_device *dev,
4038 struct rtnl_link_stats64 *stats64);
4139 static int lio_vf_rep_change_mtu(struct net_device *ndev, int new_mtu);
40
+static int lio_vf_get_port_parent_id(struct net_device *dev,
41
+ struct netdev_phys_item_id *ppid);
4242
4343 static const struct net_device_ops lio_vf_rep_ndev_ops = {
4444 .ndo_open = lio_vf_rep_open,
....@@ -48,23 +48,8 @@
4848 .ndo_get_phys_port_name = lio_vf_rep_phys_port_name,
4949 .ndo_get_stats64 = lio_vf_rep_get_stats64,
5050 .ndo_change_mtu = lio_vf_rep_change_mtu,
51
+ .ndo_get_port_parent_id = lio_vf_get_port_parent_id,
5152 };
52
-
53
-static void
54
-lio_vf_rep_send_sc_complete(struct octeon_device *oct,
55
- u32 status, void *ptr)
56
-{
57
- struct octeon_soft_command *sc = (struct octeon_soft_command *)ptr;
58
- struct lio_vf_rep_sc_ctx *ctx =
59
- (struct lio_vf_rep_sc_ctx *)sc->ctxptr;
60
- struct lio_vf_rep_resp *resp =
61
- (struct lio_vf_rep_resp *)sc->virtrptr;
62
-
63
- if (status != OCTEON_REQUEST_TIMEOUT && READ_ONCE(resp->status))
64
- WRITE_ONCE(resp->status, 0);
65
-
66
- complete(&ctx->complete);
67
-}
6853
6954 static int
7055 lio_vf_rep_send_soft_command(struct octeon_device *oct,
....@@ -72,22 +57,19 @@
7257 void *resp, int resp_size)
7358 {
7459 int tot_resp_size = sizeof(struct lio_vf_rep_resp) + resp_size;
75
- int ctx_size = sizeof(struct lio_vf_rep_sc_ctx);
7660 struct octeon_soft_command *sc = NULL;
7761 struct lio_vf_rep_resp *rep_resp;
78
- struct lio_vf_rep_sc_ctx *ctx;
7962 void *sc_req;
8063 int err;
8164
8265 sc = (struct octeon_soft_command *)
8366 octeon_alloc_soft_command(oct, req_size,
84
- tot_resp_size, ctx_size);
67
+ tot_resp_size, 0);
8568 if (!sc)
8669 return -ENOMEM;
8770
88
- ctx = (struct lio_vf_rep_sc_ctx *)sc->ctxptr;
89
- memset(ctx, 0, ctx_size);
90
- init_completion(&ctx->complete);
71
+ init_completion(&sc->complete);
72
+ sc->sc_status = OCTEON_REQUEST_PENDING;
9173
9274 sc_req = (struct lio_vf_rep_req *)sc->virtdptr;
9375 memcpy(sc_req, req, req_size);
....@@ -99,23 +81,24 @@
9981 sc->iq_no = 0;
10082 octeon_prepare_soft_command(oct, sc, OPCODE_NIC,
10183 OPCODE_NIC_VF_REP_CMD, 0, 0, 0);
102
- sc->callback = lio_vf_rep_send_sc_complete;
103
- sc->callback_arg = sc;
104
- sc->wait_time = LIO_VF_REP_REQ_TMO_MS;
10584
10685 err = octeon_send_soft_command(oct, sc);
10786 if (err == IQ_SEND_FAILED)
10887 goto free_buff;
10988
110
- wait_for_completion_timeout(&ctx->complete,
111
- msecs_to_jiffies
112
- (2 * LIO_VF_REP_REQ_TMO_MS));
89
+ err = wait_for_sc_completion_timeout(oct, sc, 0);
90
+ if (err)
91
+ return err;
92
+
11393 err = READ_ONCE(rep_resp->status) ? -EBUSY : 0;
11494 if (err)
11595 dev_err(&oct->pci_dev->dev, "VF rep send config failed\n");
116
-
117
- if (resp)
96
+ else if (resp)
11897 memcpy(resp, (rep_resp + 1), resp_size);
98
+
99
+ WRITE_ONCE(sc->caller_is_done, true);
100
+ return err;
101
+
119102 free_buff:
120103 octeon_free_soft_command(oct, sc);
121104
....@@ -189,7 +172,7 @@
189172 }
190173
191174 static void
192
-lio_vf_rep_tx_timeout(struct net_device *ndev)
175
+lio_vf_rep_tx_timeout(struct net_device *ndev, unsigned int txqueue)
193176 {
194177 netif_trans_update(ndev);
195178
....@@ -407,7 +390,7 @@
407390 }
408391
409392 sc = (struct octeon_soft_command *)
410
- octeon_alloc_soft_command(oct, 0, 0, 0);
393
+ octeon_alloc_soft_command(oct, 0, 16, 0);
411394 if (!sc) {
412395 dev_err(&oct->pci_dev->dev, "VF rep: Soft command alloc failed\n");
413396 goto xmit_failed;
....@@ -416,6 +399,7 @@
416399 /* Multiple buffers are not used for vf_rep packets. */
417400 if (skb_shinfo(skb)->nr_frags != 0) {
418401 dev_err(&oct->pci_dev->dev, "VF rep: nr_frags != 0. Dropping packet\n");
402
+ octeon_free_soft_command(oct, sc);
419403 goto xmit_failed;
420404 }
421405
....@@ -423,6 +407,7 @@
423407 skb->data, skb->len, DMA_TO_DEVICE);
424408 if (dma_mapping_error(&oct->pci_dev->dev, sc->dmadptr)) {
425409 dev_err(&oct->pci_dev->dev, "VF rep: DMA mapping failed\n");
410
+ octeon_free_soft_command(oct, sc);
426411 goto xmit_failed;
427412 }
428413
....@@ -443,6 +428,7 @@
443428 if (status == IQ_SEND_FAILED) {
444429 dma_unmap_single(&oct->pci_dev->dev, sc->dmadptr,
445430 sc->datasize, DMA_TO_DEVICE);
431
+ octeon_free_soft_command(oct, sc);
446432 goto xmit_failed;
447433 }
448434
....@@ -459,30 +445,18 @@
459445 return NETDEV_TX_OK;
460446 }
461447
462
-static int
463
-lio_vf_rep_attr_get(struct net_device *dev, struct switchdev_attr *attr)
448
+static int lio_vf_get_port_parent_id(struct net_device *dev,
449
+ struct netdev_phys_item_id *ppid)
464450 {
465451 struct lio_vf_rep_desc *vf_rep = netdev_priv(dev);
466452 struct net_device *parent_ndev = vf_rep->parent_ndev;
467453 struct lio *lio = GET_LIO(parent_ndev);
468454
469
- switch (attr->id) {
470
- case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
471
- attr->u.ppid.id_len = ETH_ALEN;
472
- ether_addr_copy(attr->u.ppid.id,
473
- (void *)&lio->linfo.hw_addr + 2);
474
- break;
475
-
476
- default:
477
- return -EOPNOTSUPP;
478
- }
455
+ ppid->id_len = ETH_ALEN;
456
+ ether_addr_copy(ppid->id, (void *)&lio->linfo.hw_addr + 2);
479457
480458 return 0;
481459 }
482
-
483
-static const struct switchdev_ops lio_vf_rep_switchdev_ops = {
484
- .switchdev_port_attr_get = lio_vf_rep_attr_get,
485
-};
486460
487461 static void
488462 lio_vf_rep_fetch_stats(struct work_struct *work)
....@@ -540,7 +514,6 @@
540514 ndev->min_mtu = LIO_MIN_MTU_SIZE;
541515 ndev->max_mtu = LIO_MAX_MTU_SIZE;
542516 ndev->netdev_ops = &lio_vf_rep_ndev_ops;
543
- SWITCHDEV_SET_OPS(ndev, &lio_vf_rep_switchdev_ops);
544517
545518 vf_rep = netdev_priv(ndev);
546519 memset(vf_rep, 0, sizeof(*vf_rep));