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 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 |
213/* 10G/25G/40G Adapter QLE41xxx*/ 214#ifndef QLOGIC_PCI_DEVICE_ID_8070 215#define QLOGIC_PCI_DEVICE_ID_8070 0x8070 216#endif 217 |
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) || |
228 (device_id == QLOGIC_PCI_DEVICE_ID_1654) || 229 (device_id == QLOGIC_PCI_DEVICE_ID_8070)) |
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 |
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; |
400 int lro_enable; |
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 |
480// for (tc = 0; tc < ha->num_tc; tc++) { 481// (void)qlnx_tx_int(ha, fp, fp->txq[tc]); 482// } |
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 |
519// for (tc = 0; tc < ha->num_tc; tc++) { 520// (void)qlnx_tx_int(ha, fp, fp->txq[tc]); 521// } |
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); |
1930 else if ((device_id == QLOGIC_PCI_DEVICE_ID_1656) || 1931 (device_id == QLOGIC_PCI_DEVICE_ID_8070)) |
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); |
1994 } else if ((device_id == QLOGIC_PCI_DEVICE_ID_1656) || 1995 (device_id == QLOGIC_PCI_DEVICE_ID_8070)) { |
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 |
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 |
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 |
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{ |
5243 struct status_block_e4 *sb_virt; |
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 --- |