Deleted Added
full compact
qlnx_os.c (319449) qlnx_os.c (320164)
1/*
2 * Copyright (c) 2017-2018 Cavium, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *

--- 18 unchanged lines hidden (view full) ---

27
28
29/*
30 * File: qlnx_os.c
31 * Author : David C Somayajulu, Cavium, Inc., San Jose, CA 95131.
32 */
33
34#include <sys/cdefs.h>
1/*
2 * Copyright (c) 2017-2018 Cavium, Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *

--- 18 unchanged lines hidden (view full) ---

27
28
29/*
30 * File: qlnx_os.c
31 * Author : David C Somayajulu, Cavium, Inc., San Jose, CA 95131.
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: stable/11/sys/dev/qlnx/qlnxe/qlnx_os.c 319449 2017-06-01 18:35:04Z davidcs $");
35__FBSDID("$FreeBSD: stable/11/sys/dev/qlnx/qlnxe/qlnx_os.c 320164 2017-06-20 19:16:06Z davidcs $");
36
37#include "qlnx_os.h"
38#include "bcm_osal.h"
39#include "reg_addr.h"
40#include "ecore_gtt_reg_addr.h"
41#include "ecore.h"
42#include "ecore_chain.h"
43#include "ecore_status.h"

--- 161 unchanged lines hidden (view full) ---

205#define QLOGIC_PCI_DEVICE_ID_1656 0x1656
206#endif
207
208/* 50G Adapter QLE45xxx*/
209#ifndef QLOGIC_PCI_DEVICE_ID_1654
210#define QLOGIC_PCI_DEVICE_ID_1654 0x1654
211#endif
212
36
37#include "qlnx_os.h"
38#include "bcm_osal.h"
39#include "reg_addr.h"
40#include "ecore_gtt_reg_addr.h"
41#include "ecore.h"
42#include "ecore_chain.h"
43#include "ecore_status.h"

--- 161 unchanged lines hidden (view full) ---

205#define QLOGIC_PCI_DEVICE_ID_1656 0x1656
206#endif
207
208/* 50G Adapter QLE45xxx*/
209#ifndef QLOGIC_PCI_DEVICE_ID_1654
210#define QLOGIC_PCI_DEVICE_ID_1654 0x1654
211#endif
212
213/* 10G/25G/40G Adapter QLE41xxx*/
214#ifndef QLOGIC_PCI_DEVICE_ID_8070
215#define QLOGIC_PCI_DEVICE_ID_8070 0x8070
216#endif
217
213static int
214qlnx_valid_device(device_t dev)
215{
216 uint16_t device_id;
217
218 device_id = pci_get_device(dev);
219
220 if ((device_id == QLOGIC_PCI_DEVICE_ID_1634) ||
221 (device_id == QLOGIC_PCI_DEVICE_ID_1644) ||
222 (device_id == QLOGIC_PCI_DEVICE_ID_1656) ||
218static int
219qlnx_valid_device(device_t dev)
220{
221 uint16_t device_id;
222
223 device_id = pci_get_device(dev);
224
225 if ((device_id == QLOGIC_PCI_DEVICE_ID_1634) ||
226 (device_id == QLOGIC_PCI_DEVICE_ID_1644) ||
227 (device_id == QLOGIC_PCI_DEVICE_ID_1656) ||
223 (device_id == QLOGIC_PCI_DEVICE_ID_1654))
228 (device_id == QLOGIC_PCI_DEVICE_ID_1654) ||
229 (device_id == QLOGIC_PCI_DEVICE_ID_8070))
224 return 0;
225
226 return -1;
227}
228
229/*
230 * Name: qlnx_pci_probe
231 * Function: Validate the PCI device to be a QLA80XX device

--- 42 unchanged lines hidden (view full) ---

274 snprintf(qlnx_dev_str, sizeof(qlnx_dev_str), "%s v%d.%d.%d",
275 "Qlogic 50GbE PCI CNA Adapter-Ethernet Function",
276 QLNX_VERSION_MAJOR, QLNX_VERSION_MINOR,
277 QLNX_VERSION_BUILD);
278 device_set_desc_copy(dev, qlnx_dev_str);
279
280 break;
281
230 return 0;
231
232 return -1;
233}
234
235/*
236 * Name: qlnx_pci_probe
237 * Function: Validate the PCI device to be a QLA80XX device

--- 42 unchanged lines hidden (view full) ---

280 snprintf(qlnx_dev_str, sizeof(qlnx_dev_str), "%s v%d.%d.%d",
281 "Qlogic 50GbE PCI CNA Adapter-Ethernet Function",
282 QLNX_VERSION_MAJOR, QLNX_VERSION_MINOR,
283 QLNX_VERSION_BUILD);
284 device_set_desc_copy(dev, qlnx_dev_str);
285
286 break;
287
288 case QLOGIC_PCI_DEVICE_ID_8070:
289 snprintf(qlnx_dev_str, sizeof(qlnx_dev_str), "%s v%d.%d.%d",
290 "Qlogic 10GbE/25GbE/40GbE PCI CNA (AH) "
291 "Adapter-Ethernet Function",
292 QLNX_VERSION_MAJOR, QLNX_VERSION_MINOR,
293 QLNX_VERSION_BUILD);
294 device_set_desc_copy(dev, qlnx_dev_str);
295
296 break;
297
282 default:
283 return (ENXIO);
284 }
285
286 return (BUS_PROBE_DEFAULT);
287}
288
289

--- 86 unchanged lines hidden (view full) ---

376static void
377qlnx_fp_taskqueue(void *context, int pending)
378{
379 struct qlnx_fastpath *fp;
380 qlnx_host_t *ha;
381 struct ifnet *ifp;
382 struct mbuf *mp;
383 int ret;
298 default:
299 return (ENXIO);
300 }
301
302 return (BUS_PROBE_DEFAULT);
303}
304
305

--- 86 unchanged lines hidden (view full) ---

392static void
393qlnx_fp_taskqueue(void *context, int pending)
394{
395 struct qlnx_fastpath *fp;
396 qlnx_host_t *ha;
397 struct ifnet *ifp;
398 struct mbuf *mp;
399 int ret;
384 int lro_enable, tc;
400 int lro_enable;
385 int rx_int = 0, total_rx_count = 0;
386 struct thread *cthread;
387
388 fp = context;
389
390 if (fp == NULL)
391 return;
392

--- 63 unchanged lines hidden (view full) ---

456
457 if (((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
458 IFF_DRV_RUNNING) || (!ha->link_up)) {
459
460 mtx_unlock(&fp->tx_mtx);
461 goto qlnx_fp_taskqueue_exit;
462 }
463
401 int rx_int = 0, total_rx_count = 0;
402 struct thread *cthread;
403
404 fp = context;
405
406 if (fp == NULL)
407 return;
408

--- 63 unchanged lines hidden (view full) ---

472
473 if (((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
474 IFF_DRV_RUNNING) || (!ha->link_up)) {
475
476 mtx_unlock(&fp->tx_mtx);
477 goto qlnx_fp_taskqueue_exit;
478 }
479
464 for (tc = 0; tc < ha->num_tc; tc++) {
465 (void)qlnx_tx_int(ha, fp, fp->txq[tc]);
466 }
480// for (tc = 0; tc < ha->num_tc; tc++) {
481// (void)qlnx_tx_int(ha, fp, fp->txq[tc]);
482// }
467
468 mp = drbr_peek(ifp, fp->tx_br);
469
470 while (mp != NULL) {
471
472 if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
473 ret = qlnx_send(ha, fp, &mp);
474 } else {

--- 20 unchanged lines hidden (view full) ---

495 }
496
497 if (fp->tx_ring_full)
498 break;
499
500 mp = drbr_peek(ifp, fp->tx_br);
501 }
502
483
484 mp = drbr_peek(ifp, fp->tx_br);
485
486 while (mp != NULL) {
487
488 if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
489 ret = qlnx_send(ha, fp, &mp);
490 } else {

--- 20 unchanged lines hidden (view full) ---

511 }
512
513 if (fp->tx_ring_full)
514 break;
515
516 mp = drbr_peek(ifp, fp->tx_br);
517 }
518
503 for (tc = 0; tc < ha->num_tc; tc++) {
504 (void)qlnx_tx_int(ha, fp, fp->txq[tc]);
505 }
519// for (tc = 0; tc < ha->num_tc; tc++) {
520// (void)qlnx_tx_int(ha, fp, fp->txq[tc]);
521// }
506
507 mtx_unlock(&fp->tx_mtx);
508
509qlnx_fp_taskqueue_exit:
510 if (rx_int) {
511 if (fp->fp_taskqueue != NULL)
512 taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task);
513 } else {

--- 1392 unchanged lines hidden (view full) ---

1906 if_initname(ifp, device_get_name(dev), device_get_unit(dev));
1907
1908 device_id = pci_get_device(ha->pci_dev);
1909
1910#if __FreeBSD_version >= 1000000
1911
1912 if (device_id == QLOGIC_PCI_DEVICE_ID_1634)
1913 ifp->if_baudrate = IF_Gbps(40);
522
523 mtx_unlock(&fp->tx_mtx);
524
525qlnx_fp_taskqueue_exit:
526 if (rx_int) {
527 if (fp->fp_taskqueue != NULL)
528 taskqueue_enqueue(fp->fp_taskqueue, &fp->fp_task);
529 } else {

--- 1392 unchanged lines hidden (view full) ---

1922 if_initname(ifp, device_get_name(dev), device_get_unit(dev));
1923
1924 device_id = pci_get_device(ha->pci_dev);
1925
1926#if __FreeBSD_version >= 1000000
1927
1928 if (device_id == QLOGIC_PCI_DEVICE_ID_1634)
1929 ifp->if_baudrate = IF_Gbps(40);
1914 else if (device_id == QLOGIC_PCI_DEVICE_ID_1656)
1930 else if ((device_id == QLOGIC_PCI_DEVICE_ID_1656) ||
1931 (device_id == QLOGIC_PCI_DEVICE_ID_8070))
1915 ifp->if_baudrate = IF_Gbps(25);
1916 else if (device_id == QLOGIC_PCI_DEVICE_ID_1654)
1917 ifp->if_baudrate = IF_Gbps(50);
1918 else if (device_id == QLOGIC_PCI_DEVICE_ID_1644)
1919 ifp->if_baudrate = IF_Gbps(100);
1920
1921 ifp->if_capabilities = IFCAP_LINKSTATE;
1922#else

--- 46 unchanged lines hidden (view full) ---

1969
1970 ifmedia_init(&ha->media, IFM_IMASK, qlnx_media_change,\
1971 qlnx_media_status);
1972
1973 if (device_id == QLOGIC_PCI_DEVICE_ID_1634) {
1974 ifmedia_add(&ha->media, (IFM_ETHER | IFM_40G_LR4), 0, NULL);
1975 ifmedia_add(&ha->media, (IFM_ETHER | IFM_40G_SR4), 0, NULL);
1976 ifmedia_add(&ha->media, (IFM_ETHER | IFM_40G_CR4), 0, NULL);
1932 ifp->if_baudrate = IF_Gbps(25);
1933 else if (device_id == QLOGIC_PCI_DEVICE_ID_1654)
1934 ifp->if_baudrate = IF_Gbps(50);
1935 else if (device_id == QLOGIC_PCI_DEVICE_ID_1644)
1936 ifp->if_baudrate = IF_Gbps(100);
1937
1938 ifp->if_capabilities = IFCAP_LINKSTATE;
1939#else

--- 46 unchanged lines hidden (view full) ---

1986
1987 ifmedia_init(&ha->media, IFM_IMASK, qlnx_media_change,\
1988 qlnx_media_status);
1989
1990 if (device_id == QLOGIC_PCI_DEVICE_ID_1634) {
1991 ifmedia_add(&ha->media, (IFM_ETHER | IFM_40G_LR4), 0, NULL);
1992 ifmedia_add(&ha->media, (IFM_ETHER | IFM_40G_SR4), 0, NULL);
1993 ifmedia_add(&ha->media, (IFM_ETHER | IFM_40G_CR4), 0, NULL);
1977 } else if (device_id == QLOGIC_PCI_DEVICE_ID_1656) {
1994 } else if ((device_id == QLOGIC_PCI_DEVICE_ID_1656) ||
1995 (device_id == QLOGIC_PCI_DEVICE_ID_8070)) {
1978 ifmedia_add(&ha->media, (IFM_ETHER | QLNX_IFM_25G_SR), 0, NULL);
1979 ifmedia_add(&ha->media, (IFM_ETHER | QLNX_IFM_25G_CR), 0, NULL);
1980 } else if (device_id == QLOGIC_PCI_DEVICE_ID_1654) {
1981 ifmedia_add(&ha->media, (IFM_ETHER | IFM_50G_KR2), 0, NULL);
1982 ifmedia_add(&ha->media, (IFM_ETHER | IFM_50G_CR2), 0, NULL);
1983 } else if (device_id == QLOGIC_PCI_DEVICE_ID_1644) {
1984 ifmedia_add(&ha->media,
1985 (IFM_ETHER | QLNX_IFM_100G_LR4), 0, NULL);

--- 1225 unchanged lines hidden (view full) ---

3211 case MEDIA_MODULE_FIBER:
3212 case MEDIA_UNSPECIFIED:
3213 if (if_link->speed == (100 * 1000))
3214 ifm_type = QLNX_IFM_100G_SR4;
3215 else if (if_link->speed == (40 * 1000))
3216 ifm_type = IFM_40G_SR4;
3217 else if (if_link->speed == (25 * 1000))
3218 ifm_type = QLNX_IFM_25G_SR;
1996 ifmedia_add(&ha->media, (IFM_ETHER | QLNX_IFM_25G_SR), 0, NULL);
1997 ifmedia_add(&ha->media, (IFM_ETHER | QLNX_IFM_25G_CR), 0, NULL);
1998 } else if (device_id == QLOGIC_PCI_DEVICE_ID_1654) {
1999 ifmedia_add(&ha->media, (IFM_ETHER | IFM_50G_KR2), 0, NULL);
2000 ifmedia_add(&ha->media, (IFM_ETHER | IFM_50G_CR2), 0, NULL);
2001 } else if (device_id == QLOGIC_PCI_DEVICE_ID_1644) {
2002 ifmedia_add(&ha->media,
2003 (IFM_ETHER | QLNX_IFM_100G_LR4), 0, NULL);

--- 1225 unchanged lines hidden (view full) ---

3229 case MEDIA_MODULE_FIBER:
3230 case MEDIA_UNSPECIFIED:
3231 if (if_link->speed == (100 * 1000))
3232 ifm_type = QLNX_IFM_100G_SR4;
3233 else if (if_link->speed == (40 * 1000))
3234 ifm_type = IFM_40G_SR4;
3235 else if (if_link->speed == (25 * 1000))
3236 ifm_type = QLNX_IFM_25G_SR;
3237 else if (if_link->speed == (10 * 1000))
3238 ifm_type = (IFM_10G_LR | IFM_10G_SR);
3239 else if (if_link->speed == (1 * 1000))
3240 ifm_type = (IFM_1000_SX | IFM_1000_LX);
3241
3219 break;
3220
3221 case MEDIA_DA_TWINAX:
3222 if (if_link->speed == (100 * 1000))
3223 ifm_type = QLNX_IFM_100G_CR4;
3224 else if (if_link->speed == (40 * 1000))
3225 ifm_type = IFM_40G_CR4;
3226 else if (if_link->speed == (25 * 1000))
3227 ifm_type = QLNX_IFM_25G_CR;
3242 break;
3243
3244 case MEDIA_DA_TWINAX:
3245 if (if_link->speed == (100 * 1000))
3246 ifm_type = QLNX_IFM_100G_CR4;
3247 else if (if_link->speed == (40 * 1000))
3248 ifm_type = IFM_40G_CR4;
3249 else if (if_link->speed == (25 * 1000))
3250 ifm_type = QLNX_IFM_25G_CR;
3251 else if (if_link->speed == (10 * 1000))
3252 ifm_type = IFM_10G_TWINAX;
3253
3228 break;
3229
3230 default :
3231 ifm_type = IFM_UNKNOWN;
3232 break;
3233 }
3234 return (ifm_type);
3235}

--- 1507 unchanged lines hidden (view full) ---

4743 cdev = ((struct ecore_hwfn *)p_hwfn)->p_dev;
4744 offset = (uint32_t)((uint8_t *)reg_addr - (uint8_t *)(cdev->regview));
4745
4746 bus_write_4(((qlnx_host_t *)cdev)->pci_reg, offset, value);
4747
4748 return;
4749}
4750
3254 break;
3255
3256 default :
3257 ifm_type = IFM_UNKNOWN;
3258 break;
3259 }
3260 return (ifm_type);
3261}

--- 1507 unchanged lines hidden (view full) ---

4769 cdev = ((struct ecore_hwfn *)p_hwfn)->p_dev;
4770 offset = (uint32_t)((uint8_t *)reg_addr - (uint8_t *)(cdev->regview));
4771
4772 bus_write_4(((qlnx_host_t *)cdev)->pci_reg, offset, value);
4773
4774 return;
4775}
4776
4777void
4778qlnx_direct_reg_wr64(void *p_hwfn, void *reg_addr, uint64_t value)
4779{
4780 uint32_t offset;
4781 struct ecore_dev *cdev;
4782
4783 cdev = ((struct ecore_hwfn *)p_hwfn)->p_dev;
4784 offset = (uint32_t)((uint8_t *)reg_addr - (uint8_t *)(cdev->regview));
4785
4786 bus_write_8(((qlnx_host_t *)cdev)->pci_reg, offset, value);
4787 return;
4788}
4789
4751void *
4752qlnx_zalloc(uint32_t size)
4753{
4754 caddr_t va;
4755
4756 va = malloc((unsigned long)size, M_QLNXBUF, M_NOWAIT);
4757 bzero(va, size);
4758 return ((void *)va);

--- 437 unchanged lines hidden (view full) ---

5196
5197 return rc;
5198}
5199
5200/* This function allocates fast-path status block memory */
5201static int
5202qlnx_alloc_mem_sb(qlnx_host_t *ha, struct ecore_sb_info *sb_info, u16 sb_id)
5203{
4790void *
4791qlnx_zalloc(uint32_t size)
4792{
4793 caddr_t va;
4794
4795 va = malloc((unsigned long)size, M_QLNXBUF, M_NOWAIT);
4796 bzero(va, size);
4797 return ((void *)va);

--- 437 unchanged lines hidden (view full) ---

5235
5236 return rc;
5237}
5238
5239/* This function allocates fast-path status block memory */
5240static int
5241qlnx_alloc_mem_sb(qlnx_host_t *ha, struct ecore_sb_info *sb_info, u16 sb_id)
5242{
5204 struct status_block *sb_virt;
5243 struct status_block_e4 *sb_virt;
5205 bus_addr_t sb_phys;
5206 int rc;
5207 uint32_t size;
5208 struct ecore_dev *cdev;
5209
5210 cdev = &ha->cdev;
5211
5212 size = sizeof(*sb_virt);

--- 1781 unchanged lines hidden ---
5244 bus_addr_t sb_phys;
5245 int rc;
5246 uint32_t size;
5247 struct ecore_dev *cdev;
5248
5249 cdev = &ha->cdev;
5250
5251 size = sizeof(*sb_virt);

--- 1781 unchanged lines hidden ---