forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-05 071106ecf68c401173c58808b1cf5f68cc50d390
kernel/drivers/net/ethernet/cavium/liquidio/lio_main.c
....@@ -21,7 +21,6 @@
2121 #include <linux/firmware.h>
2222 #include <net/vxlan.h>
2323 #include <linux/kthread.h>
24
-#include <net/switchdev.h>
2524 #include "liquidio_common.h"
2625 #include "octeon_droq.h"
2726 #include "octeon_iq.h"
....@@ -40,7 +39,6 @@
4039 MODULE_AUTHOR("Cavium Networks, <support@cavium.com>");
4140 MODULE_DESCRIPTION("Cavium LiquidIO Intelligent Server Adapter Driver");
4241 MODULE_LICENSE("GPL");
43
-MODULE_VERSION(LIQUIDIO_VERSION);
4442 MODULE_FIRMWARE(LIO_FW_DIR LIO_FW_BASE_NAME LIO_210SV_NAME
4543 "_" LIO_FW_NAME_TYPE_NIC LIO_FW_NAME_SUFFIX);
4644 MODULE_FIRMWARE(LIO_FW_DIR LIO_FW_BASE_NAME LIO_210NV_NAME
....@@ -71,9 +69,9 @@
7169 "Bitmask indicating which consoles have debug output redirected to syslog.");
7270
7371 /**
74
- * \brief determines if a given console has debug enabled.
75
- * @param console console to check
76
- * @returns 1 = enabled. 0 otherwise
72
+ * octeon_console_debug_enabled - determines if a given console has debug enabled.
73
+ * @console: console to check
74
+ * Return: 1 = enabled. 0 otherwise
7775 */
7876 static int octeon_console_debug_enabled(u32 console)
7977 {
....@@ -97,14 +95,6 @@
9795 struct lio_trusted_vf_ctx {
9896 struct completion complete;
9997 int status;
100
-};
101
-
102
-struct liquidio_rx_ctl_context {
103
- int octeon_id;
104
-
105
- wait_queue_head_t wc;
106
-
107
- int cond;
10898 };
10999
110100 struct oct_link_status_resp {
....@@ -136,7 +126,7 @@
136126 } s;
137127 };
138128
139
-/** Octeon device properties to be used by the NIC module.
129
+/* Octeon device properties to be used by the NIC module.
140130 * Each octeon device in the system will be represented
141131 * by this structure in the NIC module.
142132 */
....@@ -171,13 +161,13 @@
171161 static struct handshake handshake[MAX_OCTEON_DEVICES];
172162 static struct completion first_stage;
173163
174
-static void octeon_droq_bh(unsigned long pdev)
164
+static void octeon_droq_bh(struct tasklet_struct *t)
175165 {
176166 int q_no;
177167 int reschedule = 0;
178
- struct octeon_device *oct = (struct octeon_device *)pdev;
179
- struct octeon_device_priv *oct_priv =
180
- (struct octeon_device_priv *)oct->priv;
168
+ struct octeon_device_priv *oct_priv = from_tasklet(oct_priv, t,
169
+ droq_tasklet);
170
+ struct octeon_device *oct = oct_priv->dev;
181171
182172 for (q_no = 0; q_no < MAX_OCTEON_OUTPUT_QUEUES(oct); q_no++) {
183173 if (!(oct->io_qmask.oq & BIT_ULL(q_no)))
....@@ -232,8 +222,8 @@
232222 }
233223
234224 /**
235
- * \brief Forces all IO queues off on a given device
236
- * @param oct Pointer to Octeon device
225
+ * force_io_queues_off - Forces all IO queues off on a given device
226
+ * @oct: Pointer to Octeon device
237227 */
238228 static void force_io_queues_off(struct octeon_device *oct)
239229 {
....@@ -248,8 +238,8 @@
248238 }
249239
250240 /**
251
- * \brief Cause device to go quiet so it can be safely removed/reset/etc
252
- * @param oct Pointer to Octeon device
241
+ * pcierror_quiesce_device - Cause device to go quiet so it can be safely removed/reset/etc
242
+ * @oct: Pointer to Octeon device
253243 */
254244 static inline void pcierror_quiesce_device(struct octeon_device *oct)
255245 {
....@@ -293,8 +283,8 @@
293283 }
294284
295285 /**
296
- * \brief Cleanup PCI AER uncorrectable error status
297
- * @param dev Pointer to PCI device
286
+ * cleanup_aer_uncorrect_error_status - Cleanup PCI AER uncorrectable error status
287
+ * @dev: Pointer to PCI device
298288 */
299289 static void cleanup_aer_uncorrect_error_status(struct pci_dev *dev)
300290 {
....@@ -313,8 +303,8 @@
313303 }
314304
315305 /**
316
- * \brief Stop all PCI IO to a given device
317
- * @param dev Pointer to Octeon device
306
+ * stop_pci_io - Stop all PCI IO to a given device
307
+ * @oct: Pointer to Octeon device
318308 */
319309 static void stop_pci_io(struct octeon_device *oct)
320310 {
....@@ -342,9 +332,9 @@
342332 }
343333
344334 /**
345
- * \brief called when PCI error is detected
346
- * @param pdev Pointer to PCI device
347
- * @param state The current pci connection state
335
+ * liquidio_pcie_error_detected - called when PCI error is detected
336
+ * @pdev: Pointer to PCI device
337
+ * @state: The current pci connection state
348338 *
349339 * This function is called after a PCI bus error affecting
350340 * this device has been detected.
....@@ -372,11 +362,10 @@
372362 }
373363
374364 /**
375
- * \brief mmio handler
376
- * @param pdev Pointer to PCI device
365
+ * liquidio_pcie_mmio_enabled - mmio handler
366
+ * @pdev: Pointer to PCI device
377367 */
378
-static pci_ers_result_t liquidio_pcie_mmio_enabled(
379
- struct pci_dev *pdev __attribute__((unused)))
368
+static pci_ers_result_t liquidio_pcie_mmio_enabled(struct pci_dev __maybe_unused *pdev)
380369 {
381370 /* We should never hit this since we never ask for a reset for a Fatal
382371 * Error. We always return DISCONNECT in io_error above.
....@@ -386,14 +375,13 @@
386375 }
387376
388377 /**
389
- * \brief called after the pci bus has been reset.
390
- * @param pdev Pointer to PCI device
378
+ * liquidio_pcie_slot_reset - called after the pci bus has been reset.
379
+ * @pdev: Pointer to PCI device
391380 *
392381 * Restart the card from scratch, as if from a cold-boot. Implementation
393382 * resembles the first-half of the octeon_resume routine.
394383 */
395
-static pci_ers_result_t liquidio_pcie_slot_reset(
396
- struct pci_dev *pdev __attribute__((unused)))
384
+static pci_ers_result_t liquidio_pcie_slot_reset(struct pci_dev __maybe_unused *pdev)
397385 {
398386 /* We should never hit this since we never ask for a reset for a Fatal
399387 * Error. We always return DISCONNECT in io_error above.
....@@ -403,39 +391,20 @@
403391 }
404392
405393 /**
406
- * \brief called when traffic can start flowing again.
407
- * @param pdev Pointer to PCI device
394
+ * liquidio_pcie_resume - called when traffic can start flowing again.
395
+ * @pdev: Pointer to PCI device
408396 *
409397 * This callback is called when the error recovery driver tells us that
410398 * its OK to resume normal operation. Implementation resembles the
411399 * second-half of the octeon_resume routine.
412400 */
413
-static void liquidio_pcie_resume(struct pci_dev *pdev __attribute__((unused)))
401
+static void liquidio_pcie_resume(struct pci_dev __maybe_unused *pdev)
414402 {
415403 /* Nothing to be done here. */
416404 }
417405
418
-#ifdef CONFIG_PM
419
-/**
420
- * \brief called when suspending
421
- * @param pdev Pointer to PCI device
422
- * @param state state to suspend to
423
- */
424
-static int liquidio_suspend(struct pci_dev *pdev __attribute__((unused)),
425
- pm_message_t state __attribute__((unused)))
426
-{
427
- return 0;
428
-}
429
-
430
-/**
431
- * \brief called when resuming
432
- * @param pdev Pointer to PCI device
433
- */
434
-static int liquidio_resume(struct pci_dev *pdev __attribute__((unused)))
435
-{
436
- return 0;
437
-}
438
-#endif
406
+#define liquidio_suspend NULL
407
+#define liquidio_resume NULL
439408
440409 /* For PCI-E Advanced Error Recovery (AER) Interface */
441410 static const struct pci_error_handlers liquidio_err_handler = {
....@@ -461,24 +430,22 @@
461430 };
462431 MODULE_DEVICE_TABLE(pci, liquidio_pci_tbl);
463432
433
+static SIMPLE_DEV_PM_OPS(liquidio_pm_ops, liquidio_suspend, liquidio_resume);
434
+
464435 static struct pci_driver liquidio_pci_driver = {
465436 .name = "LiquidIO",
466437 .id_table = liquidio_pci_tbl,
467438 .probe = liquidio_probe,
468439 .remove = liquidio_remove,
469440 .err_handler = &liquidio_err_handler, /* For AER */
470
-
471
-#ifdef CONFIG_PM
472
- .suspend = liquidio_suspend,
473
- .resume = liquidio_resume,
474
-#endif
441
+ .driver.pm = &liquidio_pm_ops,
475442 #ifdef CONFIG_PCI_IOV
476443 .sriov_configure = liquidio_enable_sriov,
477444 #endif
478445 };
479446
480447 /**
481
- * \brief register PCI driver
448
+ * liquidio_init_pci - register PCI driver
482449 */
483450 static int liquidio_init_pci(void)
484451 {
....@@ -486,7 +453,7 @@
486453 }
487454
488455 /**
489
- * \brief unregister PCI driver
456
+ * liquidio_deinit_pci - unregister PCI driver
490457 */
491458 static void liquidio_deinit_pci(void)
492459 {
....@@ -494,9 +461,9 @@
494461 }
495462
496463 /**
497
- * \brief Check Tx queue status, and take appropriate action
498
- * @param lio per-network private data
499
- * @returns 0 if full, number of queues woken up otherwise
464
+ * check_txq_status - Check Tx queue status, and take appropriate action
465
+ * @lio: per-network private data
466
+ * Return: 0 if full, number of queues woken up otherwise
500467 */
501468 static inline int check_txq_status(struct lio *lio)
502469 {
....@@ -522,8 +489,8 @@
522489 }
523490
524491 /**
525
- * \brief Print link information
526
- * @param netdev network device
492
+ * print_link_info - Print link information
493
+ * @netdev: network device
527494 */
528495 static void print_link_info(struct net_device *netdev)
529496 {
....@@ -544,8 +511,8 @@
544511 }
545512
546513 /**
547
- * \brief Routine to notify MTU change
548
- * @param work work_struct data structure
514
+ * octnet_link_status_change - Routine to notify MTU change
515
+ * @work: work_struct data structure
549516 */
550517 static void octnet_link_status_change(struct work_struct *work)
551518 {
....@@ -562,8 +529,8 @@
562529 }
563530
564531 /**
565
- * \brief Sets up the mtu status change work
566
- * @param netdev network device
532
+ * setup_link_status_change_wq - Sets up the mtu status change work
533
+ * @netdev: network device
567534 */
568535 static inline int setup_link_status_change_wq(struct net_device *netdev)
569536 {
....@@ -594,9 +561,9 @@
594561 }
595562
596563 /**
597
- * \brief Update link status
598
- * @param netdev network device
599
- * @param ls link status structure
564
+ * update_link_status - Update link status
565
+ * @netdev: network device
566
+ * @ls: link status structure
600567 *
601568 * Called on receipt of a link status response from the core application to
602569 * update each interface's link status.
....@@ -642,26 +609,6 @@
642609 }
643610
644611 /**
645
- * lio_sync_octeon_time_cb - callback that is invoked when soft command
646
- * sent by lio_sync_octeon_time() has completed successfully or failed
647
- *
648
- * @oct - octeon device structure
649
- * @status - indicates success or failure
650
- * @buf - pointer to the command that was sent to firmware
651
- **/
652
-static void lio_sync_octeon_time_cb(struct octeon_device *oct,
653
- u32 status, void *buf)
654
-{
655
- struct octeon_soft_command *sc = (struct octeon_soft_command *)buf;
656
-
657
- if (status)
658
- dev_err(&oct->pci_dev->dev,
659
- "Failed to sync time to octeon; error=%d\n", status);
660
-
661
- octeon_free_soft_command(oct, sc);
662
-}
663
-
664
-/**
665612 * lio_sync_octeon_time - send latest localtime to octeon firmware so that
666613 * firmware will correct it's time, in case there is a time skew
667614 *
....@@ -677,7 +624,7 @@
677624 struct lio_time *lt;
678625 int ret;
679626
680
- sc = octeon_alloc_soft_command(oct, sizeof(struct lio_time), 0, 0);
627
+ sc = octeon_alloc_soft_command(oct, sizeof(struct lio_time), 16, 0);
681628 if (!sc) {
682629 dev_err(&oct->pci_dev->dev,
683630 "Failed to sync time to octeon: soft command allocation failed\n");
....@@ -696,15 +643,16 @@
696643 octeon_prepare_soft_command(oct, sc, OPCODE_NIC,
697644 OPCODE_NIC_SYNC_OCTEON_TIME, 0, 0, 0);
698645
699
- sc->callback = lio_sync_octeon_time_cb;
700
- sc->callback_arg = sc;
701
- sc->wait_time = 1000;
646
+ init_completion(&sc->complete);
647
+ sc->sc_status = OCTEON_REQUEST_PENDING;
702648
703649 ret = octeon_send_soft_command(oct, sc);
704650 if (ret == IQ_SEND_FAILED) {
705651 dev_err(&oct->pci_dev->dev,
706652 "Failed to sync time to octeon: failed to send soft command\n");
707653 octeon_free_soft_command(oct, sc);
654
+ } else {
655
+ WRITE_ONCE(sc->caller_is_done, true);
708656 }
709657
710658 queue_delayed_work(lio->sync_octeon_time_wq.wq,
....@@ -713,10 +661,9 @@
713661 }
714662
715663 /**
716
- * setup_sync_octeon_time_wq - Sets up the work to periodically update
717
- * local time to octeon firmware
664
+ * setup_sync_octeon_time_wq - prepare work to periodically update local time to octeon firmware
718665 *
719
- * @netdev - network device which should send time update to firmware
666
+ * @netdev: network device which should send time update to firmware
720667 **/
721668 static inline int setup_sync_octeon_time_wq(struct net_device *netdev)
722669 {
....@@ -740,10 +687,12 @@
740687 }
741688
742689 /**
743
- * cleanup_sync_octeon_time_wq - stop scheduling and destroy the work created
744
- * to periodically update local time to octeon firmware
690
+ * cleanup_sync_octeon_time_wq - destroy wq
745691 *
746
- * @netdev - network device which should send time update to firmware
692
+ * @netdev: network device which should send time update to firmware
693
+ *
694
+ * Stop scheduling and destroy the work created to periodically update local
695
+ * time to octeon firmware.
747696 **/
748697 static inline void cleanup_sync_octeon_time_wq(struct net_device *netdev)
749698 {
....@@ -878,13 +827,12 @@
878827 }
879828
880829 /**
881
- * \brief PCI probe handler
882
- * @param pdev PCI device structure
883
- * @param ent unused
830
+ * liquidio_probe - PCI probe handler
831
+ * @pdev: PCI device structure
832
+ * @ent: unused
884833 */
885834 static int
886
-liquidio_probe(struct pci_dev *pdev,
887
- const struct pci_device_id *ent __attribute__((unused)))
835
+liquidio_probe(struct pci_dev *pdev, const struct pci_device_id __maybe_unused *ent)
888836 {
889837 struct octeon_device *oct_dev = NULL;
890838 struct handshake *hs;
....@@ -974,8 +922,8 @@
974922 }
975923
976924 /**
977
- * \brief PCI FLR for each Octeon device.
978
- * @param oct octeon device
925
+ * octeon_pci_flr - PCI FLR for each Octeon device.
926
+ * @oct: octeon device
979927 */
980928 static void octeon_pci_flr(struct octeon_device *oct)
981929 {
....@@ -1001,9 +949,8 @@
1001949 }
1002950
1003951 /**
1004
- *\brief Destroy resources associated with octeon device
1005
- * @param pdev PCI device structure
1006
- * @param ent unused
952
+ * octeon_destroy_resources - Destroy resources associated with octeon device
953
+ * @oct: octeon device
1007954 */
1008955 static void octeon_destroy_resources(struct octeon_device *oct)
1009956 {
....@@ -1027,21 +974,20 @@
1027974
1028975 schedule_timeout_uninterruptible(HZ / 10);
1029976
1030
- /* fallthrough */
977
+ fallthrough;
1031978 case OCT_DEV_HOST_OK:
1032979
1033
- /* fallthrough */
1034980 case OCT_DEV_CONSOLE_INIT_DONE:
1035981 /* Remove any consoles */
1036982 octeon_remove_consoles(oct);
1037983
1038
- /* fallthrough */
984
+ fallthrough;
1039985 case OCT_DEV_IO_QUEUES_DONE:
1040
- if (wait_for_pending_requests(oct))
1041
- dev_err(&oct->pci_dev->dev, "There were pending requests\n");
1042
-
1043986 if (lio_wait_for_instr_fetch(oct))
1044987 dev_err(&oct->pci_dev->dev, "IQ had pending instructions\n");
988
+
989
+ if (wait_for_pending_requests(oct))
990
+ dev_err(&oct->pci_dev->dev, "There were pending requests\n");
1045991
1046992 /* Disable the input and output queues now. No more packets will
1047993 * arrive from Octeon, but we should wait for all packet
....@@ -1052,7 +998,32 @@
1052998 if (lio_wait_for_oq_pkts(oct))
1053999 dev_err(&oct->pci_dev->dev, "OQ had pending packets\n");
10541000
1055
- /* fallthrough */
1001
+ /* Force all requests waiting to be fetched by OCTEON to
1002
+ * complete.
1003
+ */
1004
+ for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct); i++) {
1005
+ struct octeon_instr_queue *iq;
1006
+
1007
+ if (!(oct->io_qmask.iq & BIT_ULL(i)))
1008
+ continue;
1009
+ iq = oct->instr_queue[i];
1010
+
1011
+ if (atomic_read(&iq->instr_pending)) {
1012
+ spin_lock_bh(&iq->lock);
1013
+ iq->fill_cnt = 0;
1014
+ iq->octeon_read_index = iq->host_write_index;
1015
+ iq->stats.instr_processed +=
1016
+ atomic_read(&iq->instr_pending);
1017
+ lio_process_iq_request_list(oct, iq, 0);
1018
+ spin_unlock_bh(&iq->lock);
1019
+ }
1020
+ }
1021
+
1022
+ lio_process_ordered_list(oct, 1);
1023
+ octeon_free_sc_done_list(oct);
1024
+ octeon_free_sc_zombie_list(oct);
1025
+
1026
+ fallthrough;
10561027 case OCT_DEV_INTR_SET_DONE:
10571028 /* Disable interrupts */
10581029 oct->fn_list.disable_interrupt(oct, OCTEON_ALL_INTR);
....@@ -1087,17 +1058,17 @@
10871058 kfree(oct->irq_name_storage);
10881059 oct->irq_name_storage = NULL;
10891060
1090
- /* fallthrough */
1061
+ fallthrough;
10911062 case OCT_DEV_MSIX_ALLOC_VECTOR_DONE:
10921063 if (OCTEON_CN23XX_PF(oct))
10931064 octeon_free_ioq_vector(oct);
10941065
1095
- /* fallthrough */
1066
+ fallthrough;
10961067 case OCT_DEV_MBOX_SETUP_DONE:
10971068 if (OCTEON_CN23XX_PF(oct))
10981069 oct->fn_list.free_mbox(oct);
10991070
1100
- /* fallthrough */
1071
+ fallthrough;
11011072 case OCT_DEV_IN_RESET:
11021073 case OCT_DEV_DROQ_INIT_DONE:
11031074 /* Wait for any pending operations */
....@@ -1120,11 +1091,11 @@
11201091 }
11211092 }
11221093
1123
- /* fallthrough */
1094
+ fallthrough;
11241095 case OCT_DEV_RESP_LIST_INIT_DONE:
11251096 octeon_delete_response_list(oct);
11261097
1127
- /* fallthrough */
1098
+ fallthrough;
11281099 case OCT_DEV_INSTR_QUEUE_INIT_DONE:
11291100 for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct); i++) {
11301101 if (!(oct->io_qmask.iq & BIT_ULL(i)))
....@@ -1135,16 +1106,16 @@
11351106 if (oct->sriov_info.sriov_enabled)
11361107 pci_disable_sriov(oct->pci_dev);
11371108 #endif
1138
- /* fallthrough */
1109
+ fallthrough;
11391110 case OCT_DEV_SC_BUFF_POOL_INIT_DONE:
11401111 octeon_free_sc_buffer_pool(oct);
11411112
1142
- /* fallthrough */
1113
+ fallthrough;
11431114 case OCT_DEV_DISPATCH_INIT_DONE:
11441115 octeon_delete_dispatch_list(oct);
11451116 cancel_delayed_work_sync(&oct->nic_poll_work.work);
11461117
1147
- /* fallthrough */
1118
+ fallthrough;
11481119 case OCT_DEV_PCI_MAP_DONE:
11491120 refcount = octeon_deregister_device(oct);
11501121
....@@ -1162,13 +1133,13 @@
11621133 octeon_unmap_pci_barx(oct, 0);
11631134 octeon_unmap_pci_barx(oct, 1);
11641135
1165
- /* fallthrough */
1136
+ fallthrough;
11661137 case OCT_DEV_PCI_ENABLE_DONE:
11671138 pci_clear_master(oct->pci_dev);
11681139 /* Disable the device, releasing the PCI INT */
11691140 pci_disable_device(oct->pci_dev);
11701141
1171
- /* fallthrough */
1142
+ fallthrough;
11721143 case OCT_DEV_BEGIN_STATE:
11731144 /* Nothing to be done here either */
11741145 break;
....@@ -1178,60 +1149,30 @@
11781149 }
11791150
11801151 /**
1181
- * \brief Callback for rx ctrl
1182
- * @param status status of request
1183
- * @param buf pointer to resp structure
1152
+ * send_rx_ctrl_cmd - Send Rx control command
1153
+ * @lio: per-network private data
1154
+ * @start_stop: whether to start or stop
11841155 */
1185
-static void rx_ctl_callback(struct octeon_device *oct,
1186
- u32 status,
1187
- void *buf)
1188
-{
1189
- struct octeon_soft_command *sc = (struct octeon_soft_command *)buf;
1190
- struct liquidio_rx_ctl_context *ctx;
1191
-
1192
- ctx = (struct liquidio_rx_ctl_context *)sc->ctxptr;
1193
-
1194
- oct = lio_get_device(ctx->octeon_id);
1195
- if (status)
1196
- dev_err(&oct->pci_dev->dev, "rx ctl instruction failed. Status: %llx\n",
1197
- CVM_CAST64(status));
1198
- WRITE_ONCE(ctx->cond, 1);
1199
-
1200
- /* This barrier is required to be sure that the response has been
1201
- * written fully before waking up the handler
1202
- */
1203
- wmb();
1204
-
1205
- wake_up_interruptible(&ctx->wc);
1206
-}
1207
-
1208
-/**
1209
- * \brief Send Rx control command
1210
- * @param lio per-network private data
1211
- * @param start_stop whether to start or stop
1212
- */
1213
-static void send_rx_ctrl_cmd(struct lio *lio, int start_stop)
1156
+static int send_rx_ctrl_cmd(struct lio *lio, int start_stop)
12141157 {
12151158 struct octeon_soft_command *sc;
1216
- struct liquidio_rx_ctl_context *ctx;
12171159 union octnet_cmd *ncmd;
1218
- int ctx_size = sizeof(struct liquidio_rx_ctl_context);
12191160 struct octeon_device *oct = (struct octeon_device *)lio->oct_dev;
12201161 int retval;
12211162
12221163 if (oct->props[lio->ifidx].rx_on == start_stop)
1223
- return;
1164
+ return 0;
12241165
12251166 sc = (struct octeon_soft_command *)
12261167 octeon_alloc_soft_command(oct, OCTNET_CMD_SIZE,
1227
- 16, ctx_size);
1168
+ 16, 0);
1169
+ if (!sc) {
1170
+ netif_info(lio, rx_err, lio->netdev,
1171
+ "Failed to allocate octeon_soft_command struct\n");
1172
+ return -ENOMEM;
1173
+ }
12281174
12291175 ncmd = (union octnet_cmd *)sc->virtdptr;
1230
- ctx = (struct liquidio_rx_ctl_context *)sc->ctxptr;
1231
-
1232
- WRITE_ONCE(ctx->cond, 0);
1233
- ctx->octeon_id = lio_get_device_id(oct);
1234
- init_waitqueue_head(&ctx->wc);
12351176
12361177 ncmd->u64 = 0;
12371178 ncmd->s.cmd = OCTNET_CMD_RX_CTL;
....@@ -1244,29 +1185,32 @@
12441185 octeon_prepare_soft_command(oct, sc, OPCODE_NIC,
12451186 OPCODE_NIC_CMD, 0, 0, 0);
12461187
1247
- sc->callback = rx_ctl_callback;
1248
- sc->callback_arg = sc;
1249
- sc->wait_time = 5000;
1188
+ init_completion(&sc->complete);
1189
+ sc->sc_status = OCTEON_REQUEST_PENDING;
12501190
12511191 retval = octeon_send_soft_command(oct, sc);
12521192 if (retval == IQ_SEND_FAILED) {
12531193 netif_info(lio, rx_err, lio->netdev, "Failed to send RX Control message\n");
1194
+ octeon_free_soft_command(oct, sc);
12541195 } else {
12551196 /* Sleep on a wait queue till the cond flag indicates that the
12561197 * response arrived or timed-out.
12571198 */
1258
- if (sleep_cond(&ctx->wc, &ctx->cond) == -EINTR)
1259
- return;
1199
+ retval = wait_for_sc_completion_timeout(oct, sc, 0);
1200
+ if (retval)
1201
+ return retval;
1202
+
12601203 oct->props[lio->ifidx].rx_on = start_stop;
1204
+ WRITE_ONCE(sc->caller_is_done, true);
12611205 }
12621206
1263
- octeon_free_soft_command(oct, sc);
1207
+ return retval;
12641208 }
12651209
12661210 /**
1267
- * \brief Destroy NIC device interface
1268
- * @param oct octeon device
1269
- * @param ifidx which interface to destroy
1211
+ * liquidio_destroy_nic_device - Destroy NIC device interface
1212
+ * @oct: octeon device
1213
+ * @ifidx: which interface to destroy
12701214 *
12711215 * Cleanup associated with each interface for an Octeon device when NIC
12721216 * module is being unloaded or if initialization fails during load.
....@@ -1274,8 +1218,10 @@
12741218 static void liquidio_destroy_nic_device(struct octeon_device *oct, int ifidx)
12751219 {
12761220 struct net_device *netdev = oct->props[ifidx].netdev;
1277
- struct lio *lio;
1221
+ struct octeon_device_priv *oct_priv =
1222
+ (struct octeon_device_priv *)oct->priv;
12781223 struct napi_struct *napi, *n;
1224
+ struct lio *lio;
12791225
12801226 if (!netdev) {
12811227 dev_err(&oct->pci_dev->dev, "%s No netdevice ptr for index %d\n",
....@@ -1304,6 +1250,8 @@
13041250 list_for_each_entry_safe(napi, n, &netdev->napi_list, dev_list)
13051251 netif_napi_del(napi);
13061252
1253
+ tasklet_enable(&oct_priv->droq_tasklet);
1254
+
13071255 if (atomic_read(&lio->ifstate) & LIO_IFSTATE_REGISTERED)
13081256 unregister_netdev(netdev);
13091257
....@@ -1322,8 +1270,8 @@
13221270 }
13231271
13241272 /**
1325
- * \brief Stop complete NIC functionality
1326
- * @param oct octeon device
1273
+ * liquidio_stop_nic_module - Stop complete NIC functionality
1274
+ * @oct: octeon device
13271275 */
13281276 static int liquidio_stop_nic_module(struct octeon_device *oct)
13291277 {
....@@ -1363,8 +1311,8 @@
13631311 }
13641312
13651313 /**
1366
- * \brief Cleans up resources at unload time
1367
- * @param pdev PCI device structure
1314
+ * liquidio_remove - Cleans up resources at unload time
1315
+ * @pdev: PCI device structure
13681316 */
13691317 static void liquidio_remove(struct pci_dev *pdev)
13701318 {
....@@ -1396,14 +1344,13 @@
13961344 }
13971345
13981346 /**
1399
- * \brief Identify the Octeon device and to map the BAR address space
1400
- * @param oct octeon device
1347
+ * octeon_chip_specific_setup - Identify the Octeon device and to map the BAR address space
1348
+ * @oct: octeon device
14011349 */
14021350 static int octeon_chip_specific_setup(struct octeon_device *oct)
14031351 {
14041352 u32 dev_id, rev_id;
14051353 int ret = 1;
1406
- char *s;
14071354
14081355 pci_read_config_dword(oct->pci_dev, 0, &dev_id);
14091356 pci_read_config_dword(oct->pci_dev, 8, &rev_id);
....@@ -1413,13 +1360,11 @@
14131360 case OCTEON_CN68XX_PCIID:
14141361 oct->chip_id = OCTEON_CN68XX;
14151362 ret = lio_setup_cn68xx_octeon_device(oct);
1416
- s = "CN68XX";
14171363 break;
14181364
14191365 case OCTEON_CN66XX_PCIID:
14201366 oct->chip_id = OCTEON_CN66XX;
14211367 ret = lio_setup_cn66xx_octeon_device(oct);
1422
- s = "CN66XX";
14231368 break;
14241369
14251370 case OCTEON_CN23XX_PCIID_PF:
....@@ -1432,28 +1377,19 @@
14321377 pci_sriov_set_totalvfs(oct->pci_dev,
14331378 oct->sriov_info.max_vfs);
14341379 #endif
1435
- s = "CN23XX";
14361380 break;
14371381
14381382 default:
1439
- s = "?";
14401383 dev_err(&oct->pci_dev->dev, "Unknown device found (dev_id: %x)\n",
14411384 dev_id);
14421385 }
1443
-
1444
- if (!ret)
1445
- dev_info(&oct->pci_dev->dev, "%s PASS%d.%d %s Version: %s\n", s,
1446
- OCTEON_MAJOR_REV(oct),
1447
- OCTEON_MINOR_REV(oct),
1448
- octeon_get_conf(oct)->card_name,
1449
- LIQUIDIO_VERSION);
14501386
14511387 return ret;
14521388 }
14531389
14541390 /**
1455
- * \brief PCI initialization for each Octeon device.
1456
- * @param oct octeon device
1391
+ * octeon_pci_os_setup - PCI initialization for each Octeon device.
1392
+ * @oct: octeon device
14571393 */
14581394 static int octeon_pci_os_setup(struct octeon_device *oct)
14591395 {
....@@ -1476,8 +1412,8 @@
14761412 }
14771413
14781414 /**
1479
- * \brief Unmap and free network buffer
1480
- * @param buf buffer
1415
+ * free_netbuf - Unmap and free network buffer
1416
+ * @buf: buffer
14811417 */
14821418 static void free_netbuf(void *buf)
14831419 {
....@@ -1496,8 +1432,8 @@
14961432 }
14971433
14981434 /**
1499
- * \brief Unmap and free gather buffer
1500
- * @param buf buffer
1435
+ * free_netsgbuf - Unmap and free gather buffer
1436
+ * @buf: buffer
15011437 */
15021438 static void free_netsgbuf(void *buf)
15031439 {
....@@ -1519,11 +1455,11 @@
15191455
15201456 i = 1;
15211457 while (frags--) {
1522
- struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i - 1];
1458
+ skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1];
15231459
15241460 pci_unmap_page((lio->oct_dev)->pci_dev,
15251461 g->sg[(i >> 2)].ptr[(i & 3)],
1526
- frag->size, DMA_TO_DEVICE);
1462
+ skb_frag_size(frag), DMA_TO_DEVICE);
15271463 i++;
15281464 }
15291465
....@@ -1536,8 +1472,8 @@
15361472 }
15371473
15381474 /**
1539
- * \brief Unmap and free gather buffer with response
1540
- * @param buf buffer
1475
+ * free_netsgbuf_with_resp - Unmap and free gather buffer with response
1476
+ * @buf: buffer
15411477 */
15421478 static void free_netsgbuf_with_resp(void *buf)
15431479 {
....@@ -1562,11 +1498,11 @@
15621498
15631499 i = 1;
15641500 while (frags--) {
1565
- struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i - 1];
1501
+ skb_frag_t *frag = &skb_shinfo(skb)->frags[i - 1];
15661502
15671503 pci_unmap_page((lio->oct_dev)->pci_dev,
15681504 g->sg[(i >> 2)].ptr[(i & 3)],
1569
- frag->size, DMA_TO_DEVICE);
1505
+ skb_frag_size(frag), DMA_TO_DEVICE);
15701506 i++;
15711507 }
15721508
....@@ -1580,9 +1516,9 @@
15801516 }
15811517
15821518 /**
1583
- * \brief Adjust ptp frequency
1584
- * @param ptp PTP clock info
1585
- * @param ppb how much to adjust by, in parts-per-billion
1519
+ * liquidio_ptp_adjfreq - Adjust ptp frequency
1520
+ * @ptp: PTP clock info
1521
+ * @ppb: how much to adjust by, in parts-per-billion
15861522 */
15871523 static int liquidio_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
15881524 {
....@@ -1617,9 +1553,9 @@
16171553 }
16181554
16191555 /**
1620
- * \brief Adjust ptp time
1621
- * @param ptp PTP clock info
1622
- * @param delta how much to adjust by, in nanosecs
1556
+ * liquidio_ptp_adjtime - Adjust ptp time
1557
+ * @ptp: PTP clock info
1558
+ * @delta: how much to adjust by, in nanosecs
16231559 */
16241560 static int liquidio_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
16251561 {
....@@ -1634,9 +1570,9 @@
16341570 }
16351571
16361572 /**
1637
- * \brief Get hardware clock time, including any adjustment
1638
- * @param ptp PTP clock info
1639
- * @param ts timespec
1573
+ * liquidio_ptp_gettime - Get hardware clock time, including any adjustment
1574
+ * @ptp: PTP clock info
1575
+ * @ts: timespec
16401576 */
16411577 static int liquidio_ptp_gettime(struct ptp_clock_info *ptp,
16421578 struct timespec64 *ts)
....@@ -1657,9 +1593,9 @@
16571593 }
16581594
16591595 /**
1660
- * \brief Set hardware clock time. Reset adjustment
1661
- * @param ptp PTP clock info
1662
- * @param ts timespec
1596
+ * liquidio_ptp_settime - Set hardware clock time. Reset adjustment
1597
+ * @ptp: PTP clock info
1598
+ * @ts: timespec
16631599 */
16641600 static int liquidio_ptp_settime(struct ptp_clock_info *ptp,
16651601 const struct timespec64 *ts)
....@@ -1680,22 +1616,22 @@
16801616 }
16811617
16821618 /**
1683
- * \brief Check if PTP is enabled
1684
- * @param ptp PTP clock info
1685
- * @param rq request
1686
- * @param on is it on
1619
+ * liquidio_ptp_enable - Check if PTP is enabled
1620
+ * @ptp: PTP clock info
1621
+ * @rq: request
1622
+ * @on: is it on
16871623 */
16881624 static int
1689
-liquidio_ptp_enable(struct ptp_clock_info *ptp __attribute__((unused)),
1690
- struct ptp_clock_request *rq __attribute__((unused)),
1691
- int on __attribute__((unused)))
1625
+liquidio_ptp_enable(struct ptp_clock_info __maybe_unused *ptp,
1626
+ struct ptp_clock_request __maybe_unused *rq,
1627
+ int __maybe_unused on)
16921628 {
16931629 return -EOPNOTSUPP;
16941630 }
16951631
16961632 /**
1697
- * \brief Open PTP clock source
1698
- * @param netdev network device
1633
+ * oct_ptp_open - Open PTP clock source
1634
+ * @netdev: network device
16991635 */
17001636 static void oct_ptp_open(struct net_device *netdev)
17011637 {
....@@ -1727,8 +1663,8 @@
17271663 }
17281664
17291665 /**
1730
- * \brief Init PTP clock
1731
- * @param oct octeon device
1666
+ * liquidio_ptp_init - Init PTP clock
1667
+ * @oct: octeon device
17321668 */
17331669 static void liquidio_ptp_init(struct octeon_device *oct)
17341670 {
....@@ -1744,8 +1680,8 @@
17441680 }
17451681
17461682 /**
1747
- * \brief Load firmware to device
1748
- * @param oct octeon device
1683
+ * load_firmware - Load firmware to device
1684
+ * @oct: octeon device
17491685 *
17501686 * Maps device to firmware filename, requests firmware, and downloads it
17511687 */
....@@ -1783,8 +1719,8 @@
17831719 }
17841720
17851721 /**
1786
- * \brief Poll routine for checking transmit queue status
1787
- * @param work work_struct data structure
1722
+ * octnet_poll_check_txq_status - Poll routine for checking transmit queue status
1723
+ * @work: work_struct data structure
17881724 */
17891725 static void octnet_poll_check_txq_status(struct work_struct *work)
17901726 {
....@@ -1800,8 +1736,8 @@
18001736 }
18011737
18021738 /**
1803
- * \brief Sets up the txq poll check
1804
- * @param netdev network device
1739
+ * setup_tx_poll_fn - Sets up the txq poll check
1740
+ * @netdev: network device
18051741 */
18061742 static inline int setup_tx_poll_fn(struct net_device *netdev)
18071743 {
....@@ -1833,16 +1769,21 @@
18331769 }
18341770
18351771 /**
1836
- * \brief Net device open for LiquidIO
1837
- * @param netdev network device
1772
+ * liquidio_open - Net device open for LiquidIO
1773
+ * @netdev: network device
18381774 */
18391775 static int liquidio_open(struct net_device *netdev)
18401776 {
18411777 struct lio *lio = GET_LIO(netdev);
18421778 struct octeon_device *oct = lio->oct_dev;
1779
+ struct octeon_device_priv *oct_priv =
1780
+ (struct octeon_device_priv *)oct->priv;
18431781 struct napi_struct *napi, *n;
1782
+ int ret = 0;
18441783
18451784 if (oct->props[lio->ifidx].napi_enabled == 0) {
1785
+ tasklet_disable(&oct_priv->droq_tasklet);
1786
+
18461787 list_for_each_entry_safe(napi, n, &netdev->napi_list, dev_list)
18471788 napi_enable(napi);
18481789
....@@ -1857,13 +1798,10 @@
18571798
18581799 ifstate_set(lio, LIO_IFSTATE_RUNNING);
18591800
1860
- if (OCTEON_CN23XX_PF(oct)) {
1861
- if (!oct->msix_on)
1862
- if (setup_tx_poll_fn(netdev))
1863
- return -1;
1864
- } else {
1865
- if (setup_tx_poll_fn(netdev))
1866
- return -1;
1801
+ if (!OCTEON_CN23XX_PF(oct) || !oct->msix_on) {
1802
+ ret = setup_tx_poll_fn(netdev);
1803
+ if (ret)
1804
+ goto err_poll;
18671805 }
18681806
18691807 netif_tx_start_all_queues(netdev);
....@@ -1874,23 +1812,55 @@
18741812 netif_info(lio, ifup, lio->netdev, "Interface Open, ready for traffic\n");
18751813
18761814 /* tell Octeon to start forwarding packets to host */
1877
- send_rx_ctrl_cmd(lio, 1);
1815
+ ret = send_rx_ctrl_cmd(lio, 1);
1816
+ if (ret)
1817
+ goto err_rx_ctrl;
1818
+
1819
+ /* start periodical statistics fetch */
1820
+ INIT_DELAYED_WORK(&lio->stats_wk.work, lio_fetch_stats);
1821
+ lio->stats_wk.ctxptr = lio;
1822
+ schedule_delayed_work(&lio->stats_wk.work, msecs_to_jiffies
1823
+ (LIQUIDIO_NDEV_STATS_POLL_TIME_MS));
18781824
18791825 dev_info(&oct->pci_dev->dev, "%s interface is opened\n",
18801826 netdev->name);
18811827
18821828 return 0;
1829
+
1830
+err_rx_ctrl:
1831
+ if (!OCTEON_CN23XX_PF(oct) || !oct->msix_on)
1832
+ cleanup_tx_poll_fn(netdev);
1833
+err_poll:
1834
+ if (lio->ptp_clock) {
1835
+ ptp_clock_unregister(lio->ptp_clock);
1836
+ lio->ptp_clock = NULL;
1837
+ }
1838
+
1839
+ if (oct->props[lio->ifidx].napi_enabled == 1) {
1840
+ list_for_each_entry_safe(napi, n, &netdev->napi_list, dev_list)
1841
+ napi_disable(napi);
1842
+
1843
+ oct->props[lio->ifidx].napi_enabled = 0;
1844
+
1845
+ if (OCTEON_CN23XX_PF(oct))
1846
+ oct->droq[0]->ops.poll_mode = 0;
1847
+ }
1848
+
1849
+ return ret;
18831850 }
18841851
18851852 /**
1886
- * \brief Net device stop for LiquidIO
1887
- * @param netdev network device
1853
+ * liquidio_stop - Net device stop for LiquidIO
1854
+ * @netdev: network device
18881855 */
18891856 static int liquidio_stop(struct net_device *netdev)
18901857 {
18911858 struct lio *lio = GET_LIO(netdev);
18921859 struct octeon_device *oct = lio->oct_dev;
1860
+ struct octeon_device_priv *oct_priv =
1861
+ (struct octeon_device_priv *)oct->priv;
18931862 struct napi_struct *napi, *n;
1863
+ int ret = 0;
18941864
18951865 ifstate_reset(lio, LIO_IFSTATE_RUNNING);
18961866
....@@ -1907,7 +1877,9 @@
19071877 lio->link_changes++;
19081878
19091879 /* Tell Octeon that nic interface is down. */
1910
- send_rx_ctrl_cmd(lio, 0);
1880
+ ret = send_rx_ctrl_cmd(lio, 0);
1881
+ if (ret)
1882
+ return ret;
19111883
19121884 if (OCTEON_CN23XX_PF(oct)) {
19131885 if (!oct->msix_on)
....@@ -1915,6 +1887,8 @@
19151887 } else {
19161888 cleanup_tx_poll_fn(netdev);
19171889 }
1890
+
1891
+ cancel_delayed_work_sync(&lio->stats_wk.work);
19181892
19191893 if (lio->ptp_clock) {
19201894 ptp_clock_unregister(lio->ptp_clock);
....@@ -1934,16 +1908,18 @@
19341908
19351909 if (OCTEON_CN23XX_PF(oct))
19361910 oct->droq[0]->ops.poll_mode = 0;
1911
+
1912
+ tasklet_enable(&oct_priv->droq_tasklet);
19371913 }
19381914
19391915 dev_info(&oct->pci_dev->dev, "%s interface is stopped\n", netdev->name);
19401916
1941
- return 0;
1917
+ return ret;
19421918 }
19431919
19441920 /**
1945
- * \brief Converts a mask based on net device flags
1946
- * @param netdev network device
1921
+ * get_new_flags - Converts a mask based on net device flags
1922
+ * @netdev: network device
19471923 *
19481924 * This routine generates a octnet_ifflags mask from the net device flags
19491925 * received from the OS.
....@@ -1975,8 +1951,8 @@
19751951 }
19761952
19771953 /**
1978
- * \brief Net device set_multicast_list
1979
- * @param netdev network device
1954
+ * liquidio_set_mcast_list - Net device set_multicast_list
1955
+ * @netdev: network device
19801956 */
19811957 static void liquidio_set_mcast_list(struct net_device *netdev)
19821958 {
....@@ -2014,18 +1990,18 @@
20141990 /* Apparently, any activity in this call from the kernel has to
20151991 * be atomic. So we won't wait for response.
20161992 */
2017
- nctrl.wait_time = 0;
20181993
20191994 ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl);
2020
- if (ret < 0) {
1995
+ if (ret) {
20211996 dev_err(&oct->pci_dev->dev, "DEVFLAGS change failed in core (ret: 0x%x)\n",
20221997 ret);
20231998 }
20241999 }
20252000
20262001 /**
2027
- * \brief Net device set_mac_address
2028
- * @param netdev network device
2002
+ * liquidio_set_mac - Net device set_mac_address
2003
+ * @netdev: network device
2004
+ * @p: pointer to sockaddr
20292005 */
20302006 static int liquidio_set_mac(struct net_device *netdev, void *p)
20312007 {
....@@ -2046,8 +2022,6 @@
20462022 nctrl.ncmd.s.more = 1;
20472023 nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
20482024 nctrl.netpndev = (u64)netdev;
2049
- nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
2050
- nctrl.wait_time = 100;
20512025
20522026 nctrl.udd[0] = 0;
20532027 /* The MAC Address is presented in network byte order. */
....@@ -2058,6 +2032,14 @@
20582032 dev_err(&oct->pci_dev->dev, "MAC Address change failed\n");
20592033 return -ENOMEM;
20602034 }
2035
+
2036
+ if (nctrl.sc_status) {
2037
+ dev_err(&oct->pci_dev->dev,
2038
+ "%s: MAC Address change failed. sc return=%x\n",
2039
+ __func__, nctrl.sc_status);
2040
+ return -EIO;
2041
+ }
2042
+
20612043 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
20622044 memcpy(((u8 *)&lio->linfo.hw_addr) + 2, addr->sa_data, ETH_ALEN);
20632045
....@@ -2111,7 +2093,6 @@
21112093 lstats->rx_packets = pkts;
21122094 lstats->rx_dropped = drop;
21132095
2114
- octnet_get_link_stats(netdev);
21152096 lstats->multicast = oct->link_stats.fromwire.fw_total_mcast;
21162097 lstats->collisions = oct->link_stats.fromhost.total_collisions;
21172098
....@@ -2138,10 +2119,9 @@
21382119 }
21392120
21402121 /**
2141
- * \brief Handler for SIOCSHWTSTAMP ioctl
2142
- * @param netdev network device
2143
- * @param ifr interface request
2144
- * @param cmd command
2122
+ * hwtstamp_ioctl - Handler for SIOCSHWTSTAMP ioctl
2123
+ * @netdev: network device
2124
+ * @ifr: interface request
21452125 */
21462126 static int hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr)
21472127 {
....@@ -2196,10 +2176,10 @@
21962176 }
21972177
21982178 /**
2199
- * \brief ioctl handler
2200
- * @param netdev network device
2201
- * @param ifr interface request
2202
- * @param cmd command
2179
+ * liquidio_ioctl - ioctl handler
2180
+ * @netdev: network device
2181
+ * @ifr: interface request
2182
+ * @cmd: command
22032183 */
22042184 static int liquidio_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
22052185 {
....@@ -2209,16 +2189,17 @@
22092189 case SIOCSHWTSTAMP:
22102190 if (lio->oct_dev->ptp_enable)
22112191 return hwtstamp_ioctl(netdev, ifr);
2212
- /* fall through */
2192
+ fallthrough;
22132193 default:
22142194 return -EOPNOTSUPP;
22152195 }
22162196 }
22172197
22182198 /**
2219
- * \brief handle a Tx timestamp response
2220
- * @param status response status
2221
- * @param buf pointer to skb
2199
+ * handle_timestamp - handle a Tx timestamp response
2200
+ * @oct: octeon device
2201
+ * @status: response status
2202
+ * @buf: pointer to skb
22222203 */
22232204 static void handle_timestamp(struct octeon_device *oct,
22242205 u32 status,
....@@ -2259,10 +2240,12 @@
22592240 tx_buffer_free(skb);
22602241 }
22612242
2262
-/* \brief Send a data packet that will be timestamped
2263
- * @param oct octeon device
2264
- * @param ndata pointer to network data
2265
- * @param finfo pointer to private network data
2243
+/**
2244
+ * send_nic_timestamp_pkt - Send a data packet that will be timestamped
2245
+ * @oct: octeon device
2246
+ * @ndata: pointer to network data
2247
+ * @finfo: pointer to private network data
2248
+ * @xmit_more: more is coming
22662249 */
22672250 static inline int send_nic_timestamp_pkt(struct octeon_device *oct,
22682251 struct octnic_data_pkt *ndata,
....@@ -2318,10 +2301,12 @@
23182301 return retval;
23192302 }
23202303
2321
-/** \brief Transmit networks packets to the Octeon interface
2322
- * @param skbuff skbuff struct to be passed to network layer.
2323
- * @param netdev pointer to network device
2324
- * @returns whether the packet was transmitted to the device okay or not
2304
+/**
2305
+ * liquidio_xmit - Transmit networks packets to the Octeon interface
2306
+ * @skb: skbuff struct to be passed to network layer.
2307
+ * @netdev: pointer to network device
2308
+ *
2309
+ * Return: whether the packet was transmitted to the device okay or not
23252310 * (NETDEV_TX_OK or NETDEV_TX_BUSY)
23262311 */
23272312 static netdev_tx_t liquidio_xmit(struct sk_buff *skb, struct net_device *netdev)
....@@ -2431,7 +2416,7 @@
24312416
24322417 } else {
24332418 int i, frags;
2434
- struct skb_frag_struct *frag;
2419
+ skb_frag_t *frag;
24352420 struct octnic_gather *g;
24362421
24372422 spin_lock(&lio->glist_lock[q_idx]);
....@@ -2469,11 +2454,9 @@
24692454 frag = &skb_shinfo(skb)->frags[i - 1];
24702455
24712456 g->sg[(i >> 2)].ptr[(i & 3)] =
2472
- dma_map_page(&oct->pci_dev->dev,
2473
- frag->page.p,
2474
- frag->page_offset,
2475
- frag->size,
2476
- DMA_TO_DEVICE);
2457
+ skb_frag_dma_map(&oct->pci_dev->dev,
2458
+ frag, 0, skb_frag_size(frag),
2459
+ DMA_TO_DEVICE);
24772460
24782461 if (dma_mapping_error(&oct->pci_dev->dev,
24792462 g->sg[i >> 2].ptr[i & 3])) {
....@@ -2485,7 +2468,7 @@
24852468 frag = &skb_shinfo(skb)->frags[j - 1];
24862469 dma_unmap_page(&oct->pci_dev->dev,
24872470 g->sg[j >> 2].ptr[j & 3],
2488
- frag->size,
2471
+ skb_frag_size(frag),
24892472 DMA_TO_DEVICE);
24902473 }
24912474 dev_err(&oct->pci_dev->dev, "%s DMA mapping error 3\n",
....@@ -2493,7 +2476,8 @@
24932476 return NETDEV_TX_BUSY;
24942477 }
24952478
2496
- add_sg_size(&g->sg[(i >> 2)], frag->size, (i & 3));
2479
+ add_sg_size(&g->sg[(i >> 2)], skb_frag_size(frag),
2480
+ (i & 3));
24972481 i++;
24982482 }
24992483
....@@ -2529,7 +2513,7 @@
25292513 irh->vlan = skb_vlan_tag_get(skb) & 0xfff;
25302514 }
25312515
2532
- xmit_more = skb->xmit_more;
2516
+ xmit_more = netdev_xmit_more();
25332517
25342518 if (unlikely(cmdsetup.s.timestamp))
25352519 status = send_nic_timestamp_pkt(oct, &ndata, finfo, xmit_more);
....@@ -2567,10 +2551,12 @@
25672551 return NETDEV_TX_OK;
25682552 }
25692553
2570
-/** \brief Network device Tx timeout
2571
- * @param netdev pointer to network device
2554
+/**
2555
+ * liquidio_tx_timeout - Network device Tx timeout
2556
+ * @netdev: pointer to network device
2557
+ * @txqueue: index of the hung transmit queue
25722558 */
2573
-static void liquidio_tx_timeout(struct net_device *netdev)
2559
+static void liquidio_tx_timeout(struct net_device *netdev, unsigned int txqueue)
25742560 {
25752561 struct lio *lio;
25762562
....@@ -2598,14 +2584,15 @@
25982584 nctrl.ncmd.s.cmd = OCTNET_CMD_ADD_VLAN_FILTER;
25992585 nctrl.ncmd.s.param1 = vid;
26002586 nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
2601
- nctrl.wait_time = 100;
26022587 nctrl.netpndev = (u64)netdev;
26032588 nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
26042589
26052590 ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl);
2606
- if (ret < 0) {
2591
+ if (ret) {
26072592 dev_err(&oct->pci_dev->dev, "Add VLAN filter failed in core (ret: 0x%x)\n",
26082593 ret);
2594
+ if (ret > 0)
2595
+ ret = -EIO;
26092596 }
26102597
26112598 return ret;
....@@ -2626,24 +2613,25 @@
26262613 nctrl.ncmd.s.cmd = OCTNET_CMD_DEL_VLAN_FILTER;
26272614 nctrl.ncmd.s.param1 = vid;
26282615 nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
2629
- nctrl.wait_time = 100;
26302616 nctrl.netpndev = (u64)netdev;
26312617 nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
26322618
26332619 ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl);
2634
- if (ret < 0) {
2620
+ if (ret) {
26352621 dev_err(&oct->pci_dev->dev, "Del VLAN filter failed in core (ret: 0x%x)\n",
26362622 ret);
2623
+ if (ret > 0)
2624
+ ret = -EIO;
26372625 }
26382626 return ret;
26392627 }
26402628
2641
-/** Sending command to enable/disable RX checksum offload
2642
- * @param netdev pointer to network device
2643
- * @param command OCTNET_CMD_TNL_RX_CSUM_CTL
2644
- * @param rx_cmd_bit OCTNET_CMD_RXCSUM_ENABLE/
2645
- * OCTNET_CMD_RXCSUM_DISABLE
2646
- * @returns SUCCESS or FAILURE
2629
+/**
2630
+ * liquidio_set_rxcsum_command - Sending command to enable/disable RX checksum offload
2631
+ * @netdev: pointer to network device
2632
+ * @command: OCTNET_CMD_TNL_RX_CSUM_CTL
2633
+ * @rx_cmd: OCTNET_CMD_RXCSUM_ENABLE/OCTNET_CMD_RXCSUM_DISABLE
2634
+ * Returns: SUCCESS or FAILURE
26472635 */
26482636 static int liquidio_set_rxcsum_command(struct net_device *netdev, int command,
26492637 u8 rx_cmd)
....@@ -2659,26 +2647,28 @@
26592647 nctrl.ncmd.s.cmd = command;
26602648 nctrl.ncmd.s.param1 = rx_cmd;
26612649 nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
2662
- nctrl.wait_time = 100;
26632650 nctrl.netpndev = (u64)netdev;
26642651 nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
26652652
26662653 ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl);
2667
- if (ret < 0) {
2654
+ if (ret) {
26682655 dev_err(&oct->pci_dev->dev,
26692656 "DEVFLAGS RXCSUM change failed in core(ret:0x%x)\n",
26702657 ret);
2658
+ if (ret > 0)
2659
+ ret = -EIO;
26712660 }
26722661 return ret;
26732662 }
26742663
2675
-/** Sending command to add/delete VxLAN UDP port to firmware
2676
- * @param netdev pointer to network device
2677
- * @param command OCTNET_CMD_VXLAN_PORT_CONFIG
2678
- * @param vxlan_port VxLAN port to be added or deleted
2679
- * @param vxlan_cmd_bit OCTNET_CMD_VXLAN_PORT_ADD,
2664
+/**
2665
+ * liquidio_vxlan_port_command - Sending command to add/delete VxLAN UDP port to firmware
2666
+ * @netdev: pointer to network device
2667
+ * @command: OCTNET_CMD_VXLAN_PORT_CONFIG
2668
+ * @vxlan_port: VxLAN port to be added or deleted
2669
+ * @vxlan_cmd_bit: OCTNET_CMD_VXLAN_PORT_ADD,
26802670 * OCTNET_CMD_VXLAN_PORT_DEL
2681
- * @returns SUCCESS or FAILURE
2671
+ * Return: SUCCESS or FAILURE
26822672 */
26832673 static int liquidio_vxlan_port_command(struct net_device *netdev, int command,
26842674 u16 vxlan_port, u8 vxlan_cmd_bit)
....@@ -2695,23 +2685,54 @@
26952685 nctrl.ncmd.s.more = vxlan_cmd_bit;
26962686 nctrl.ncmd.s.param1 = vxlan_port;
26972687 nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
2698
- nctrl.wait_time = 100;
26992688 nctrl.netpndev = (u64)netdev;
27002689 nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
27012690
27022691 ret = octnet_send_nic_ctrl_pkt(lio->oct_dev, &nctrl);
2703
- if (ret < 0) {
2692
+ if (ret) {
27042693 dev_err(&oct->pci_dev->dev,
27052694 "VxLAN port add/delete failed in core (ret:0x%x)\n",
27062695 ret);
2696
+ if (ret > 0)
2697
+ ret = -EIO;
27072698 }
27082699 return ret;
27092700 }
27102701
2711
-/** \brief Net device fix features
2712
- * @param netdev pointer to network device
2713
- * @param request features requested
2714
- * @returns updated features list
2702
+static int liquidio_udp_tunnel_set_port(struct net_device *netdev,
2703
+ unsigned int table, unsigned int entry,
2704
+ struct udp_tunnel_info *ti)
2705
+{
2706
+ return liquidio_vxlan_port_command(netdev,
2707
+ OCTNET_CMD_VXLAN_PORT_CONFIG,
2708
+ htons(ti->port),
2709
+ OCTNET_CMD_VXLAN_PORT_ADD);
2710
+}
2711
+
2712
+static int liquidio_udp_tunnel_unset_port(struct net_device *netdev,
2713
+ unsigned int table,
2714
+ unsigned int entry,
2715
+ struct udp_tunnel_info *ti)
2716
+{
2717
+ return liquidio_vxlan_port_command(netdev,
2718
+ OCTNET_CMD_VXLAN_PORT_CONFIG,
2719
+ htons(ti->port),
2720
+ OCTNET_CMD_VXLAN_PORT_DEL);
2721
+}
2722
+
2723
+static const struct udp_tunnel_nic_info liquidio_udp_tunnels = {
2724
+ .set_port = liquidio_udp_tunnel_set_port,
2725
+ .unset_port = liquidio_udp_tunnel_unset_port,
2726
+ .tables = {
2727
+ { .n_entries = 1024, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, },
2728
+ },
2729
+};
2730
+
2731
+/**
2732
+ * liquidio_fix_features - Net device fix features
2733
+ * @netdev: pointer to network device
2734
+ * @request: features requested
2735
+ * Return: updated features list
27152736 */
27162737 static netdev_features_t liquidio_fix_features(struct net_device *netdev,
27172738 netdev_features_t request)
....@@ -2747,9 +2768,10 @@
27472768 return request;
27482769 }
27492770
2750
-/** \brief Net device set features
2751
- * @param netdev pointer to network device
2752
- * @param features features to enable/disable
2771
+/**
2772
+ * liquidio_set_features - Net device set features
2773
+ * @netdev: pointer to network device
2774
+ * @features: features to enable/disable
27532775 */
27542776 static int liquidio_set_features(struct net_device *netdev,
27552777 netdev_features_t features)
....@@ -2796,36 +2818,13 @@
27962818 return 0;
27972819 }
27982820
2799
-static void liquidio_add_vxlan_port(struct net_device *netdev,
2800
- struct udp_tunnel_info *ti)
2801
-{
2802
- if (ti->type != UDP_TUNNEL_TYPE_VXLAN)
2803
- return;
2804
-
2805
- liquidio_vxlan_port_command(netdev,
2806
- OCTNET_CMD_VXLAN_PORT_CONFIG,
2807
- htons(ti->port),
2808
- OCTNET_CMD_VXLAN_PORT_ADD);
2809
-}
2810
-
2811
-static void liquidio_del_vxlan_port(struct net_device *netdev,
2812
- struct udp_tunnel_info *ti)
2813
-{
2814
- if (ti->type != UDP_TUNNEL_TYPE_VXLAN)
2815
- return;
2816
-
2817
- liquidio_vxlan_port_command(netdev,
2818
- OCTNET_CMD_VXLAN_PORT_CONFIG,
2819
- htons(ti->port),
2820
- OCTNET_CMD_VXLAN_PORT_DEL);
2821
-}
2822
-
28232821 static int __liquidio_set_vf_mac(struct net_device *netdev, int vfidx,
28242822 u8 *mac, bool is_admin_assigned)
28252823 {
28262824 struct lio *lio = GET_LIO(netdev);
28272825 struct octeon_device *oct = lio->oct_dev;
28282826 struct octnic_ctrl_pkt nctrl;
2827
+ int ret = 0;
28292828
28302829 if (!is_valid_ether_addr(mac))
28312830 return -EINVAL;
....@@ -2839,12 +2838,13 @@
28392838 nctrl.ncmd.s.cmd = OCTNET_CMD_CHANGE_MACADDR;
28402839 /* vfidx is 0 based, but vf_num (param1) is 1 based */
28412840 nctrl.ncmd.s.param1 = vfidx + 1;
2842
- nctrl.ncmd.s.param2 = (is_admin_assigned ? 1 : 0);
28432841 nctrl.ncmd.s.more = 1;
28442842 nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
28452843 nctrl.netpndev = (u64)netdev;
2846
- nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
2847
- nctrl.wait_time = LIO_CMD_WAIT_TM;
2844
+ if (is_admin_assigned) {
2845
+ nctrl.ncmd.s.param2 = true;
2846
+ nctrl.cb_fn = liquidio_link_ctrl_cmd_completion;
2847
+ }
28482848
28492849 nctrl.udd[0] = 0;
28502850 /* The MAC Address is presented in network byte order. */
....@@ -2852,9 +2852,11 @@
28522852
28532853 oct->sriov_info.vf_macaddr[vfidx] = nctrl.udd[0];
28542854
2855
- octnet_send_nic_ctrl_pkt(oct, &nctrl);
2855
+ ret = octnet_send_nic_ctrl_pkt(oct, &nctrl);
2856
+ if (ret > 0)
2857
+ ret = -EIO;
28562858
2857
- return 0;
2859
+ return ret;
28582860 }
28592861
28602862 static int liquidio_set_vf_mac(struct net_device *netdev, int vfidx, u8 *mac)
....@@ -2873,6 +2875,62 @@
28732875 return retval;
28742876 }
28752877
2878
+static int liquidio_set_vf_spoofchk(struct net_device *netdev, int vfidx,
2879
+ bool enable)
2880
+{
2881
+ struct lio *lio = GET_LIO(netdev);
2882
+ struct octeon_device *oct = lio->oct_dev;
2883
+ struct octnic_ctrl_pkt nctrl;
2884
+ int retval;
2885
+
2886
+ if (!(oct->fw_info.app_cap_flags & LIQUIDIO_SPOOFCHK_CAP)) {
2887
+ netif_info(lio, drv, lio->netdev,
2888
+ "firmware does not support spoofchk\n");
2889
+ return -EOPNOTSUPP;
2890
+ }
2891
+
2892
+ if (vfidx < 0 || vfidx >= oct->sriov_info.num_vfs_alloced) {
2893
+ netif_info(lio, drv, lio->netdev, "Invalid vfidx %d\n", vfidx);
2894
+ return -EINVAL;
2895
+ }
2896
+
2897
+ if (enable) {
2898
+ if (oct->sriov_info.vf_spoofchk[vfidx])
2899
+ return 0;
2900
+ } else {
2901
+ /* Clear */
2902
+ if (!oct->sriov_info.vf_spoofchk[vfidx])
2903
+ return 0;
2904
+ }
2905
+
2906
+ memset(&nctrl, 0, sizeof(struct octnic_ctrl_pkt));
2907
+ nctrl.ncmd.s.cmdgroup = OCTNET_CMD_GROUP1;
2908
+ nctrl.ncmd.s.cmd = OCTNET_CMD_SET_VF_SPOOFCHK;
2909
+ nctrl.ncmd.s.param1 =
2910
+ vfidx + 1; /* vfidx is 0 based,
2911
+ * but vf_num (param1) is 1 based
2912
+ */
2913
+ nctrl.ncmd.s.param2 = enable;
2914
+ nctrl.ncmd.s.more = 0;
2915
+ nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
2916
+ nctrl.cb_fn = NULL;
2917
+
2918
+ retval = octnet_send_nic_ctrl_pkt(oct, &nctrl);
2919
+
2920
+ if (retval) {
2921
+ netif_info(lio, drv, lio->netdev,
2922
+ "Failed to set VF %d spoofchk %s\n", vfidx,
2923
+ enable ? "on" : "off");
2924
+ return -1;
2925
+ }
2926
+
2927
+ oct->sriov_info.vf_spoofchk[vfidx] = enable;
2928
+ netif_info(lio, drv, lio->netdev, "VF %u spoofchk is %s\n", vfidx,
2929
+ enable ? "on" : "off");
2930
+
2931
+ return 0;
2932
+}
2933
+
28762934 static int liquidio_set_vf_vlan(struct net_device *netdev, int vfidx,
28772935 u16 vlan, u8 qos, __be16 vlan_proto)
28782936 {
....@@ -2880,6 +2938,7 @@
28802938 struct octeon_device *oct = lio->oct_dev;
28812939 struct octnic_ctrl_pkt nctrl;
28822940 u16 vlantci;
2941
+ int ret = 0;
28832942
28842943 if (vfidx < 0 || vfidx >= oct->sriov_info.num_vfs_alloced)
28852944 return -EINVAL;
....@@ -2911,13 +2970,17 @@
29112970 nctrl.ncmd.s.more = 0;
29122971 nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
29132972 nctrl.cb_fn = NULL;
2914
- nctrl.wait_time = LIO_CMD_WAIT_TM;
29152973
2916
- octnet_send_nic_ctrl_pkt(oct, &nctrl);
2974
+ ret = octnet_send_nic_ctrl_pkt(oct, &nctrl);
2975
+ if (ret) {
2976
+ if (ret > 0)
2977
+ ret = -EIO;
2978
+ return ret;
2979
+ }
29172980
29182981 oct->sriov_info.vf_vlantci[vfidx] = vlantci;
29192982
2920
- return 0;
2983
+ return ret;
29212984 }
29222985
29232986 static int liquidio_get_vf_config(struct net_device *netdev, int vfidx,
....@@ -2930,6 +2993,8 @@
29302993 if (vfidx < 0 || vfidx >= oct->sriov_info.num_vfs_alloced)
29312994 return -EINVAL;
29322995
2996
+ memset(ivi, 0, sizeof(struct ifla_vf_info));
2997
+
29332998 ivi->vf = vfidx;
29342999 macaddr = 2 + (u8 *)&oct->sriov_info.vf_macaddr[vfidx];
29353000 ether_addr_copy(&ivi->mac[0], macaddr);
....@@ -2941,33 +3006,22 @@
29413006 else
29423007 ivi->trusted = false;
29433008 ivi->linkstate = oct->sriov_info.vf_linkstate[vfidx];
3009
+ ivi->spoofchk = oct->sriov_info.vf_spoofchk[vfidx];
3010
+ ivi->max_tx_rate = lio->linfo.link.s.speed;
3011
+ ivi->min_tx_rate = 0;
3012
+
29443013 return 0;
2945
-}
2946
-
2947
-static void trusted_vf_callback(struct octeon_device *oct_dev,
2948
- u32 status, void *ptr)
2949
-{
2950
- struct octeon_soft_command *sc = (struct octeon_soft_command *)ptr;
2951
- struct lio_trusted_vf_ctx *ctx;
2952
-
2953
- ctx = (struct lio_trusted_vf_ctx *)sc->ctxptr;
2954
- ctx->status = status;
2955
-
2956
- complete(&ctx->complete);
29573014 }
29583015
29593016 static int liquidio_send_vf_trust_cmd(struct lio *lio, int vfidx, bool trusted)
29603017 {
29613018 struct octeon_device *oct = lio->oct_dev;
2962
- struct lio_trusted_vf_ctx *ctx;
29633019 struct octeon_soft_command *sc;
2964
- int ctx_size, retval;
3020
+ int retval;
29653021
2966
- ctx_size = sizeof(struct lio_trusted_vf_ctx);
2967
- sc = octeon_alloc_soft_command(oct, 0, 0, ctx_size);
2968
-
2969
- ctx = (struct lio_trusted_vf_ctx *)sc->ctxptr;
2970
- init_completion(&ctx->complete);
3022
+ sc = octeon_alloc_soft_command(oct, 0, 16, 0);
3023
+ if (!sc)
3024
+ return -ENOMEM;
29713025
29723026 sc->iq_no = lio->linfo.txpciq[0].s.q_no;
29733027
....@@ -2976,23 +3030,21 @@
29763030 OPCODE_NIC_SET_TRUSTED_VF, 0, vfidx + 1,
29773031 trusted);
29783032
2979
- sc->callback = trusted_vf_callback;
2980
- sc->callback_arg = sc;
2981
- sc->wait_time = 1000;
3033
+ init_completion(&sc->complete);
3034
+ sc->sc_status = OCTEON_REQUEST_PENDING;
29823035
29833036 retval = octeon_send_soft_command(oct, sc);
29843037 if (retval == IQ_SEND_FAILED) {
3038
+ octeon_free_soft_command(oct, sc);
29853039 retval = -1;
29863040 } else {
29873041 /* Wait for response or timeout */
2988
- if (wait_for_completion_timeout(&ctx->complete,
2989
- msecs_to_jiffies(2000)))
2990
- retval = ctx->status;
2991
- else
2992
- retval = -1;
2993
- }
3042
+ retval = wait_for_sc_completion_timeout(oct, sc, 0);
3043
+ if (retval)
3044
+ return (retval);
29943045
2995
- octeon_free_soft_command(oct, sc);
3046
+ WRITE_ONCE(sc->caller_is_done, true);
3047
+ }
29963048
29973049 return retval;
29983050 }
....@@ -3055,6 +3107,7 @@
30553107 struct lio *lio = GET_LIO(netdev);
30563108 struct octeon_device *oct = lio->oct_dev;
30573109 struct octnic_ctrl_pkt nctrl;
3110
+ int ret = 0;
30583111
30593112 if (vfidx < 0 || vfidx >= oct->sriov_info.num_vfs_alloced)
30603113 return -EINVAL;
....@@ -3070,13 +3123,15 @@
30703123 nctrl.ncmd.s.more = 0;
30713124 nctrl.iq_no = lio->linfo.txpciq[0].s.q_no;
30723125 nctrl.cb_fn = NULL;
3073
- nctrl.wait_time = LIO_CMD_WAIT_TM;
30743126
3075
- octnet_send_nic_ctrl_pkt(oct, &nctrl);
3127
+ ret = octnet_send_nic_ctrl_pkt(oct, &nctrl);
30763128
3077
- oct->sriov_info.vf_linkstate[vfidx] = linkstate;
3129
+ if (!ret)
3130
+ oct->sriov_info.vf_linkstate[vfidx] = linkstate;
3131
+ else if (ret > 0)
3132
+ ret = -EIO;
30783133
3079
- return 0;
3134
+ return ret;
30803135 }
30813136
30823137 static int
....@@ -3094,7 +3149,8 @@
30943149 }
30953150
30963151 static int
3097
-liquidio_eswitch_mode_set(struct devlink *devlink, u16 mode)
3152
+liquidio_eswitch_mode_set(struct devlink *devlink, u16 mode,
3153
+ struct netlink_ext_ack *extack)
30983154 {
30993155 struct lio_devlink_priv *priv;
31003156 struct octeon_device *oct;
....@@ -3133,7 +3189,8 @@
31333189 };
31343190
31353191 static int
3136
-lio_pf_switchdev_attr_get(struct net_device *dev, struct switchdev_attr *attr)
3192
+liquidio_get_port_parent_id(struct net_device *dev,
3193
+ struct netdev_phys_item_id *ppid)
31373194 {
31383195 struct lio *lio = GET_LIO(dev);
31393196 struct octeon_device *oct = lio->oct_dev;
....@@ -3141,23 +3198,11 @@
31413198 if (oct->eswitch_mode != DEVLINK_ESWITCH_MODE_SWITCHDEV)
31423199 return -EOPNOTSUPP;
31433200
3144
- switch (attr->id) {
3145
- case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
3146
- attr->u.ppid.id_len = ETH_ALEN;
3147
- ether_addr_copy(attr->u.ppid.id,
3148
- (void *)&lio->linfo.hw_addr + 2);
3149
- break;
3150
-
3151
- default:
3152
- return -EOPNOTSUPP;
3153
- }
3201
+ ppid->id_len = ETH_ALEN;
3202
+ ether_addr_copy(ppid->id, (void *)&lio->linfo.hw_addr + 2);
31543203
31553204 return 0;
31563205 }
3157
-
3158
-static const struct switchdev_ops lio_pf_switchdev_ops = {
3159
- .switchdev_port_attr_get = lio_pf_switchdev_attr_get,
3160
-};
31613206
31623207 static int liquidio_get_vf_stats(struct net_device *netdev, int vfidx,
31633208 struct ifla_vf_stats *vf_stats)
....@@ -3199,17 +3244,20 @@
31993244 .ndo_do_ioctl = liquidio_ioctl,
32003245 .ndo_fix_features = liquidio_fix_features,
32013246 .ndo_set_features = liquidio_set_features,
3202
- .ndo_udp_tunnel_add = liquidio_add_vxlan_port,
3203
- .ndo_udp_tunnel_del = liquidio_del_vxlan_port,
3247
+ .ndo_udp_tunnel_add = udp_tunnel_nic_add_port,
3248
+ .ndo_udp_tunnel_del = udp_tunnel_nic_del_port,
32043249 .ndo_set_vf_mac = liquidio_set_vf_mac,
32053250 .ndo_set_vf_vlan = liquidio_set_vf_vlan,
32063251 .ndo_get_vf_config = liquidio_get_vf_config,
3252
+ .ndo_set_vf_spoofchk = liquidio_set_vf_spoofchk,
32073253 .ndo_set_vf_trust = liquidio_set_vf_trust,
32083254 .ndo_set_vf_link_state = liquidio_set_vf_link_state,
32093255 .ndo_get_vf_stats = liquidio_get_vf_stats,
3256
+ .ndo_get_port_parent_id = liquidio_get_port_parent_id,
32103257 };
32113258
3212
-/** \brief Entry point for the liquidio module
3259
+/**
3260
+ * liquidio_init - Entry point for the liquidio module
32133261 */
32143262 static int __init liquidio_init(void)
32153263 {
....@@ -3292,8 +3340,8 @@
32923340 }
32933341
32943342 /**
3295
- * \brief Setup network interfaces
3296
- * @param octeon_dev octeon device
3343
+ * setup_nic_devices - Setup network interfaces
3344
+ * @octeon_dev: octeon device
32973345 *
32983346 * Called during init time for each device. It assumes the NIC
32993347 * is already up and running. The link information for each
....@@ -3307,7 +3355,6 @@
33073355 unsigned long micro;
33083356 u32 cur_ver;
33093357 struct octeon_soft_command *sc;
3310
- struct liquidio_if_cfg_context *ctx;
33113358 struct liquidio_if_cfg_resp *resp;
33123359 struct octdev_props *props;
33133360 int retval, num_iqueues, num_oqueues;
....@@ -3315,7 +3362,7 @@
33153362 union oct_nic_if_cfg if_cfg;
33163363 unsigned int base_queue;
33173364 unsigned int gmx_port_id;
3318
- u32 resp_size, ctx_size, data_size;
3365
+ u32 resp_size, data_size;
33193366 u32 ifidx_or_pfnum;
33203367 struct lio_version *vdata;
33213368 struct devlink *devlink;
....@@ -3340,13 +3387,11 @@
33403387
33413388 for (i = 0; i < octeon_dev->ifcount; i++) {
33423389 resp_size = sizeof(struct liquidio_if_cfg_resp);
3343
- ctx_size = sizeof(struct liquidio_if_cfg_context);
33443390 data_size = sizeof(struct lio_version);
33453391 sc = (struct octeon_soft_command *)
33463392 octeon_alloc_soft_command(octeon_dev, data_size,
3347
- resp_size, ctx_size);
3393
+ resp_size, 0);
33483394 resp = (struct liquidio_if_cfg_resp *)sc->virtrptr;
3349
- ctx = (struct liquidio_if_cfg_context *)sc->ctxptr;
33503395 vdata = (struct lio_version *)sc->virtdptr;
33513396
33523397 *((u64 *)vdata) = 0;
....@@ -3376,9 +3421,6 @@
33763421 dev_dbg(&octeon_dev->pci_dev->dev,
33773422 "requesting config for interface %d, iqs %d, oqs %d\n",
33783423 ifidx_or_pfnum, num_iqueues, num_oqueues);
3379
- WRITE_ONCE(ctx->cond, 0);
3380
- ctx->octeon_id = lio_get_device_id(octeon_dev);
3381
- init_waitqueue_head(&ctx->wc);
33823424
33833425 if_cfg.u64 = 0;
33843426 if_cfg.s.num_iqueues = num_iqueues;
....@@ -3392,9 +3434,8 @@
33923434 OPCODE_NIC_IF_CFG, 0,
33933435 if_cfg.u64, 0);
33943436
3395
- sc->callback = lio_if_cfg_callback;
3396
- sc->callback_arg = sc;
3397
- sc->wait_time = LIO_IFCFG_WAIT_TIME;
3437
+ init_completion(&sc->complete);
3438
+ sc->sc_status = OCTEON_REQUEST_PENDING;
33983439
33993440 retval = octeon_send_soft_command(octeon_dev, sc);
34003441 if (retval == IQ_SEND_FAILED) {
....@@ -3402,22 +3443,26 @@
34023443 "iq/oq config failed status: %x\n",
34033444 retval);
34043445 /* Soft instr is freed by driver in case of failure. */
3405
- goto setup_nic_dev_fail;
3446
+ octeon_free_soft_command(octeon_dev, sc);
3447
+ return(-EIO);
34063448 }
34073449
34083450 /* Sleep on a wait queue till the cond flag indicates that the
34093451 * response arrived or timed-out.
34103452 */
3411
- if (sleep_cond(&ctx->wc, &ctx->cond) == -EINTR) {
3412
- dev_err(&octeon_dev->pci_dev->dev, "Wait interrupted\n");
3413
- goto setup_nic_wait_intr;
3414
- }
3453
+ retval = wait_for_sc_completion_timeout(octeon_dev, sc, 0);
3454
+ if (retval)
3455
+ return retval;
34153456
34163457 retval = resp->status;
34173458 if (retval) {
34183459 dev_err(&octeon_dev->pci_dev->dev, "iq/oq config failed\n");
3419
- goto setup_nic_dev_fail;
3460
+ WRITE_ONCE(sc->caller_is_done, true);
3461
+ goto setup_nic_dev_done;
34203462 }
3463
+ snprintf(octeon_dev->fw_info.liquidio_firmware_version,
3464
+ 32, "%s",
3465
+ resp->cfg_info.liquidio_firmware_version);
34213466
34223467 /* Verify f/w version (in case of 'auto' loading from flash) */
34233468 fw_ver = octeon_dev->fw_info.liquidio_firmware_version;
....@@ -3427,7 +3472,8 @@
34273472 dev_err(&octeon_dev->pci_dev->dev,
34283473 "Unmatched firmware version. Expected %s.x, got %s.\n",
34293474 LIQUIDIO_BASE_VERSION, fw_ver);
3430
- goto setup_nic_dev_fail;
3475
+ WRITE_ONCE(sc->caller_is_done, true);
3476
+ goto setup_nic_dev_done;
34313477 } else if (atomic_read(octeon_dev->adapter_fw_state) ==
34323478 FW_IS_PRELOADED) {
34333479 dev_info(&octeon_dev->pci_dev->dev,
....@@ -3454,7 +3500,8 @@
34543500 "Got bad iqueues (%016llx) or oqueues (%016llx) from firmware.\n",
34553501 resp->cfg_info.iqmask,
34563502 resp->cfg_info.oqmask);
3457
- goto setup_nic_dev_fail;
3503
+ WRITE_ONCE(sc->caller_is_done, true);
3504
+ goto setup_nic_dev_done;
34583505 }
34593506
34603507 if (OCTEON_CN6XXX(octeon_dev)) {
....@@ -3473,7 +3520,8 @@
34733520
34743521 if (!netdev) {
34753522 dev_err(&octeon_dev->pci_dev->dev, "Device allocation failed\n");
3476
- goto setup_nic_dev_fail;
3523
+ WRITE_ONCE(sc->caller_is_done, true);
3524
+ goto setup_nic_dev_done;
34773525 }
34783526
34793527 SET_NETDEV_DEV(netdev, &octeon_dev->pci_dev->dev);
....@@ -3482,20 +3530,21 @@
34823530 * netdev tasks.
34833531 */
34843532 netdev->netdev_ops = &lionetdevops;
3485
- SWITCHDEV_SET_OPS(netdev, &lio_pf_switchdev_ops);
34863533
34873534 retval = netif_set_real_num_rx_queues(netdev, num_oqueues);
34883535 if (retval) {
34893536 dev_err(&octeon_dev->pci_dev->dev,
34903537 "setting real number rx failed\n");
3491
- goto setup_nic_dev_fail;
3538
+ WRITE_ONCE(sc->caller_is_done, true);
3539
+ goto setup_nic_dev_free;
34923540 }
34933541
34943542 retval = netif_set_real_num_tx_queues(netdev, num_iqueues);
34953543 if (retval) {
34963544 dev_err(&octeon_dev->pci_dev->dev,
34973545 "setting real number tx failed\n");
3498
- goto setup_nic_dev_fail;
3546
+ WRITE_ONCE(sc->caller_is_done, true);
3547
+ goto setup_nic_dev_free;
34993548 }
35003549
35013550 lio = GET_LIO(netdev);
....@@ -3521,6 +3570,8 @@
35213570 lio->linfo.hw_addr = resp->cfg_info.linfo.hw_addr;
35223571 lio->linfo.gmxport = resp->cfg_info.linfo.gmxport;
35233572 lio->linfo.link.u64 = resp->cfg_info.linfo.link.u64;
3573
+
3574
+ WRITE_ONCE(sc->caller_is_done, true);
35243575
35253576 lio->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE);
35263577
....@@ -3549,6 +3600,8 @@
35493600
35503601 netdev->hw_enc_features = (lio->enc_dev_capability &
35513602 ~NETIF_F_LRO);
3603
+
3604
+ netdev->udp_tunnel_nic_info = &liquidio_udp_tunnels;
35523605
35533606 lio->dev_capability |= NETIF_F_GSO_UDP_TUNNEL;
35543607
....@@ -3588,7 +3641,7 @@
35883641 dev_err(&octeon_dev->pci_dev->dev,
35893642 "Error setting VF%d MAC address\n",
35903643 j);
3591
- goto setup_nic_dev_fail;
3644
+ goto setup_nic_dev_free;
35923645 }
35933646 }
35943647
....@@ -3610,7 +3663,7 @@
36103663 lio->linfo.num_txpciq,
36113664 lio->linfo.num_rxpciq)) {
36123665 dev_err(&octeon_dev->pci_dev->dev, "I/O queues creation failed\n");
3613
- goto setup_nic_dev_fail;
3666
+ goto setup_nic_dev_free;
36143667 }
36153668
36163669 ifstate_set(lio, LIO_IFSTATE_DROQ_OPS);
....@@ -3621,7 +3674,7 @@
36213674 if (lio_setup_glists(octeon_dev, lio, num_iqueues)) {
36223675 dev_err(&octeon_dev->pci_dev->dev,
36233676 "Gather list allocation failed\n");
3624
- goto setup_nic_dev_fail;
3677
+ goto setup_nic_dev_free;
36253678 }
36263679
36273680 /* Register ethtool support */
....@@ -3643,20 +3696,20 @@
36433696 OCTNET_CMD_VERBOSE_ENABLE, 0);
36443697
36453698 if (setup_link_status_change_wq(netdev))
3646
- goto setup_nic_dev_fail;
3699
+ goto setup_nic_dev_free;
36473700
36483701 if ((octeon_dev->fw_info.app_cap_flags &
36493702 LIQUIDIO_TIME_SYNC_CAP) &&
36503703 setup_sync_octeon_time_wq(netdev))
3651
- goto setup_nic_dev_fail;
3704
+ goto setup_nic_dev_free;
36523705
36533706 if (setup_rx_oom_poll_fn(netdev))
3654
- goto setup_nic_dev_fail;
3707
+ goto setup_nic_dev_free;
36553708
36563709 /* Register the network device with the OS */
36573710 if (register_netdev(netdev)) {
36583711 dev_err(&octeon_dev->pci_dev->dev, "Device registration failed\n");
3659
- goto setup_nic_dev_fail;
3712
+ goto setup_nic_dev_free;
36603713 }
36613714
36623715 dev_dbg(&octeon_dev->pci_dev->dev,
....@@ -3678,8 +3731,6 @@
36783731
36793732 dev_dbg(&octeon_dev->pci_dev->dev,
36803733 "NIC ifidx:%d Setup successful\n", i);
3681
-
3682
- octeon_free_soft_command(octeon_dev, sc);
36833734
36843735 if (octeon_dev->subsystem_id ==
36853736 OCTEON_CN2350_25GB_SUBSYS_ID ||
....@@ -3709,13 +3760,20 @@
37093760 }
37103761 octeon_dev->speed_boot = octeon_dev->speed_setting;
37113762
3763
+ /* don't read FEC setting if unsupported by f/w (see above) */
3764
+ if (octeon_dev->speed_boot == 25 &&
3765
+ !octeon_dev->no_speed_setting) {
3766
+ liquidio_get_fec(lio);
3767
+ octeon_dev->props[lio->ifidx].fec_boot =
3768
+ octeon_dev->props[lio->ifidx].fec;
3769
+ }
37123770 }
37133771
37143772 devlink = devlink_alloc(&liquidio_devlink_ops,
37153773 sizeof(struct lio_devlink_priv));
37163774 if (!devlink) {
37173775 dev_err(&octeon_dev->pci_dev->dev, "devlink alloc failed\n");
3718
- goto setup_nic_wait_intr;
3776
+ goto setup_nic_dev_free;
37193777 }
37203778
37213779 lio_devlink = devlink_priv(devlink);
....@@ -3725,7 +3783,7 @@
37253783 devlink_free(devlink);
37263784 dev_err(&octeon_dev->pci_dev->dev,
37273785 "devlink registration failed\n");
3728
- goto setup_nic_wait_intr;
3786
+ goto setup_nic_dev_free;
37293787 }
37303788
37313789 octeon_dev->devlink = devlink;
....@@ -3733,17 +3791,16 @@
37333791
37343792 return 0;
37353793
3736
-setup_nic_dev_fail:
3737
-
3738
- octeon_free_soft_command(octeon_dev, sc);
3739
-
3740
-setup_nic_wait_intr:
3794
+setup_nic_dev_free:
37413795
37423796 while (i--) {
37433797 dev_err(&octeon_dev->pci_dev->dev,
37443798 "NIC ifidx:%d Setup failed\n", i);
37453799 liquidio_destroy_nic_device(octeon_dev, i);
37463800 }
3801
+
3802
+setup_nic_dev_done:
3803
+
37473804 return -ENODEV;
37483805 }
37493806
....@@ -3848,8 +3905,8 @@
38483905 #endif
38493906
38503907 /**
3851
- * \brief initialize the NIC
3852
- * @param oct octeon device
3908
+ * liquidio_init_nic_module - initialize the NIC
3909
+ * @oct: octeon device
38533910 *
38543911 * This initialization routine is called once the Octeon device application is
38553912 * up and running
....@@ -3904,9 +3961,10 @@
39043961 }
39053962
39063963 /**
3907
- * \brief starter callback that invokes the remaining initialization work after
3908
- * the NIC is up and running.
3909
- * @param octptr work struct work_struct
3964
+ * nic_starter - finish init
3965
+ * @work: work struct work_struct
3966
+ *
3967
+ * starter callback that invokes the remaining initialization work after the NIC is up and running.
39103968 */
39113969 static void nic_starter(struct work_struct *work)
39123970 {
....@@ -3999,8 +4057,8 @@
39994057 }
40004058
40014059 /**
4002
- * \brief Device initialization for each Octeon device that is probed
4003
- * @param octeon_dev octeon device
4060
+ * octeon_device_init - Device initialization for each Octeon device that is probed
4061
+ * @octeon_dev: octeon device
40044062 */
40054063 static int octeon_device_init(struct octeon_device *octeon_dev)
40064064 {
....@@ -4169,8 +4227,7 @@
41694227
41704228 /* Initialize the tasklet that handles output queue packet processing.*/
41714229 dev_dbg(&octeon_dev->pci_dev->dev, "Initializing droq tasklet\n");
4172
- tasklet_init(&oct_priv->droq_tasklet, octeon_droq_bh,
4173
- (unsigned long)octeon_dev);
4230
+ tasklet_setup(&oct_priv->droq_tasklet, octeon_droq_bh);
41744231
41754232 /* Setup the interrupt handler and record the INT SUM register address
41764233 */
....@@ -4274,16 +4331,17 @@
42744331 complete(&handshake[octeon_dev->octeon_id].init);
42754332
42764333 atomic_set(&octeon_dev->status, OCT_DEV_HOST_OK);
4334
+ oct_priv->dev = octeon_dev;
42774335
42784336 return 0;
42794337 }
42804338
42814339 /**
4282
- * \brief Debug console print function
4283
- * @param octeon_dev octeon device
4284
- * @param console_num console number
4285
- * @param prefix first portion of line to display
4286
- * @param suffix second portion of line to display
4340
+ * octeon_dbg_console_print - Debug console print function
4341
+ * @oct: octeon device
4342
+ * @console_num: console number
4343
+ * @prefix: first portion of line to display
4344
+ * @suffix: second portion of line to display
42874345 *
42884346 * The OCTEON debug console outputs entire lines (excluding '\n').
42894347 * Normally, the line will be passed in the 'prefix' parameter.
....@@ -4306,7 +4364,7 @@
43064364 }
43074365
43084366 /**
4309
- * \brief Exits the module
4367
+ * liquidio_exit - Exits the module
43104368 */
43114369 static void __exit liquidio_exit(void)
43124370 {