/* * Aic94xx SAS/SATA driver initialization. * * Copyright (C) 2005 Adaptec, Inc. All rights reserved. * Copyright (C) 2005 Luben Tuikov * * This file is licensed under GPLv2. * * This file is part of the aic94xx driver. * * The aic94xx driver is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; version 2 of the * License. * * The aic94xx driver is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with the aic94xx driver; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * */ #include #include #include #include #include #include #include #include #include "aic94xx.h" #include "aic94xx_reg.h" #include "aic94xx_hwi.h" #include "aic94xx_seq.h" #include "aic94xx_sds.h" /* The format is "version.release.patchlevel" */ #define ASD_DRIVER_VERSION "1.0.3" static int use_msi = 0; module_param_named(use_msi, use_msi, int, S_IRUGO); MODULE_PARM_DESC(use_msi, "\n" "\tEnable(1) or disable(0) using PCI MSI.\n" "\tDefault: 0"); static struct scsi_transport_template *aic94xx_transport_template; static int asd_scan_finished(struct Scsi_Host *, unsigned long); static void asd_scan_start(struct Scsi_Host *); static struct scsi_host_template aic94xx_sht = { .module = THIS_MODULE, /* .name is initialized */ .name = "aic94xx", .queuecommand = sas_queuecommand, .target_alloc = sas_target_alloc, .slave_configure = sas_slave_configure, .scan_finished = asd_scan_finished, .scan_start = asd_scan_start, .change_queue_depth = sas_change_queue_depth, .bios_param = sas_bios_param, .can_queue = 1, .this_id = -1, .sg_tablesize = SG_ALL, .max_sectors = SCSI_DEFAULT_MAX_SECTORS, .use_clustering = ENABLE_CLUSTERING, .eh_device_reset_handler = sas_eh_device_reset_handler, .eh_bus_reset_handler = sas_eh_bus_reset_handler, .target_destroy = sas_target_destroy, .ioctl = sas_ioctl, .track_queue_depth = 1, }; static int asd_map_memio(struct asd_ha_struct *asd_ha) { int err, i; struct asd_ha_addrspace *io_handle; asd_ha->iospace = 0; for (i = 0; i < 3; i += 2) { io_handle = &asd_ha->io_handle[i==0?0:1]; io_handle->start = pci_resource_start(asd_ha->pcidev, i); io_handle->len = pci_resource_len(asd_ha->pcidev, i); io_handle->flags = pci_resource_flags(asd_ha->pcidev, i); err = -ENODEV; if (!io_handle->start || !io_handle->len) { asd_printk("MBAR%d start or length for %s is 0.\n", i==0?0:1, pci_name(asd_ha->pcidev)); goto Err; } err = pci_request_region(asd_ha->pcidev, i, ASD_DRIVER_NAME); if (err) { asd_printk("couldn't reserve memory region for %s\n", pci_name(asd_ha->pcidev)); goto Err; } io_handle->addr = ioremap(io_handle->start, io_handle->len); if (!io_handle->addr) { asd_printk("couldn't map MBAR%d of %s\n", i==0?0:1, pci_name(asd_ha->pcidev)); err = -ENOMEM; goto Err_unreq; } } return 0; Err_unreq: pci_release_region(asd_ha->pcidev, i); Err: if (i > 0) { io_handle = &asd_ha->io_handle[0]; iounmap(io_handle->addr); pci_release_region(asd_ha->pcidev, 0); } return err; } static void asd_unmap_memio(struct asd_ha_struct *asd_ha) { struct asd_ha_addrspace *io_handle; io_handle = &asd_ha->io_handle[1]; iounmap(io_handle->addr); pci_release_region(asd_ha->pcidev, 2); io_handle = &asd_ha->io_handle[0]; iounmap(io_handle->addr); pci_release_region(asd_ha->pcidev, 0); } static int asd_map_ioport(struct asd_ha_struct *asd_ha) { int i = PCI_IOBAR_OFFSET, err; struct asd_ha_addrspace *io_handle = &asd_ha->io_handle[0]; asd_ha->iospace = 1; io_handle->start = pci_resource_start(asd_ha->pcidev, i); io_handle->len = pci_resource_len(asd_ha->pcidev, i); io_handle->flags = pci_resource_flags(asd_ha->pcidev, i); io_handle->addr = (void __iomem *) io_handle->start; if (!io_handle->start || !io_handle->len) { asd_printk("couldn't get IO ports for %s\n", pci_name(asd_ha->pcidev)); return -ENODEV; } err = pci_request_region(asd_ha->pcidev, i, ASD_DRIVER_NAME); if (err) { asd_printk("couldn't reserve io space for %s\n", pci_name(asd_ha->pcidev)); } return err; } static void asd_unmap_ioport(struct asd_ha_struct *asd_ha) { pci_release_region(asd_ha->pcidev, PCI_IOBAR_OFFSET); } static int asd_map_ha(struct asd_ha_struct *asd_ha) { int err; u16 cmd_reg; err = pci_read_config_word(asd_ha->pcidev, PCI_COMMAND, &cmd_reg); if (err) { asd_printk("couldn't read command register of %s\n", pci_name(asd_ha->pcidev)); goto Err; } err = -ENODEV; if (cmd_reg & PCI_COMMAND_MEMORY) { if ((err = asd_map_memio(asd_ha))) goto Err; } else if (cmd_reg & PCI_COMMAND_IO) { if ((err = asd_map_ioport(asd_ha))) goto Err; asd_printk("%s ioport mapped -- upgrade your hardware\n", pci_name(asd_ha->pcidev)); } else { asd_printk("no proper device access to %s\n", pci_name(asd_ha->pcidev)); goto Err; } return 0; Err: return err; } static void asd_unmap_ha(struct asd_ha_struct *asd_ha) { if (asd_ha->iospace) asd_unmap_ioport(asd_ha); else asd_unmap_memio(asd_ha); } static const char *asd_dev_rev[30] = { [0] = "A0", [1] = "A1", [8] = "B0", }; static int asd_common_setup(struct asd_ha_struct *asd_ha) { int err, i; asd_ha->revision_id = asd_ha->pcidev->revision; err = -ENODEV; if (asd_ha->revision_id < AIC9410_DEV_REV_B0) { asd_printk("%s is revision %s (%X), which is not supported\n", pci_name(asd_ha->pcidev), asd_dev_rev[asd_ha->revision_id], asd_ha->revision_id); goto Err; } /* Provide some sane default values. */ asd_ha->hw_prof.max_scbs = 512; asd_ha->hw_prof.max_ddbs = ASD_MAX_DDBS; asd_ha->h
##############################################################################
# Copyright (c) 2017 Nokia and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
---

schema: "yardstick:task:0.1"
description: >
    Yardstick TC077 config file;
    Extend TC008 to run pktgen-dpdk (sender) and testpmd (receiver) inside VM.

scenarios:
{% for pkt_size in [64, 128, 256, 512, 1024, 1280, 1518] %}
  {% for num_ports in [1, 10, 50, 100, 500, 1000] %}
-
  type: PktgenDPDK
  options:
    packetsize: {{pkt_size}}
    number_of_ports: {{num_ports}}
    duration: 20

  host: demeter.yardstick-TC077
  target: poseidon.yardstick-TC077

  runner:
    type: Iteration
    iterations: 3
    interval: 1

  sla:
    max_ppm: 1
    action: rate-control
  {% endfor %}
{% endfor %}

context:
  name: yardstick-TC077
  image: yardstick-dpdk-image
  flavor: yardstick-dpdk-flavor
  user: ubuntu

  placement_groups:
    pgrp1:
      policy: "availability"

  servers:
    demeter:
      floating_ip: true
      placement: "pgrp1"
    poseidon:
      floating_ip: true
      placement: "pgrp1"

  networks:
    test:
      cidr: '10.0.1.0/24'
    test2:
      cidr: '10.0.2.0/24'
      provider: "sriov"
eturn err; } static void asd_free_queues(struct asd_ha_struct *asd_ha) { unsigned long flags; LIST_HEAD(pending); struct list_head *n, *pos; spin_lock_irqsave(&asd_ha->seq.pend_q_lock, flags); asd_ha->seq.pending = 0; list_splice_init(&asd_ha->seq.pend_q, &pending); spin_unlock_irqrestore(&asd_ha->seq.pend_q_lock, flags); if (!list_empty(&pending)) ASD_DPRINTK("Uh-oh! Pending is not empty!\n"); list_for_each_safe(pos, n, &pending) { struct asd_ascb *ascb = list_entry(pos, struct asd_ascb, list); /* * Delete unexpired ascb timers. This may happen if we issue * a CONTROL PHY scb to an adapter and rmmod before the scb * times out. Apparently we don't wait for the CONTROL PHY * to complete, so it doesn't matter if we kill the timer. */ del_timer_sync(&ascb->timer); WARN_ON(ascb->scb->header.opcode != CONTROL_PHY); list_del_init(pos); ASD_DPRINTK("freeing from pending\n"); asd_ascb_free(ascb); } } static void asd_turn_off_leds(struct asd_ha_struct *asd_ha) { u8 phy_mask = asd_ha->hw_prof.enabled_phys; u8 i; for_each_phy(phy_mask, phy_mask, i) { asd_turn_led(asd_ha, i, 0); asd_control_led(asd_ha, i, 0); } } static void asd_pci_remove(struct pci_dev *dev) { struct asd_ha_struct *asd_ha = pci_get_drvdata(dev); if (!asd_ha) return; asd_unregister_sas_ha(asd_ha); asd_disable_ints(asd_ha); asd_remove_dev_attrs(asd_ha); /* XXX more here as needed */ free_irq(dev->irq, asd_ha); if (use_msi) pci_disable_msi(asd_ha->pcidev); asd_turn_off_leds(asd_ha); asd_chip_hardrst(asd_ha); asd_free_queues(asd_ha); asd_destroy_ha_caches(asd_ha); asd_unmap_ha(asd_ha); kfree(asd_ha); pci_disable_device(dev); return; } static void asd_scan_start(struct Scsi_Host *shost) { struct asd_ha_struct *asd_ha; int err; asd_ha = SHOST_TO_SAS_HA(shost)->lldd_ha; err = asd_enable_phys(asd_ha, asd_ha->hw_prof.enabled_phys); if (err) asd_printk("Couldn't enable phys, err:%d\n", err); } static int asd_scan_finished(struct Scsi_Host *shost, unsigned long time) { /* give the phy enabling interrupt event time to come in (1s * is empirically about all it takes) */ if (time < HZ) return 0; /* Wait for discovery to finish */ sas_drain_work(SHOST_TO_SAS_HA(shost)); return 1; } static ssize_t asd_version_show(struct device_driver *driver, char *buf) { return snprintf(buf, PAGE_SIZE, "%s\n", ASD_DRIVER_VERSION); } static DRIVER_ATTR(version, S_IRUGO, asd_version_show, NULL); static int asd_create_driver_attrs(struct device_driver *driver) { return driver_create_file(driver, &driver_attr_version); } static void asd_remove_driver_attrs(struct device_driver *driver) { driver_remove_file(driver, &driver_attr_version); } static struct sas_domain_function_template aic94xx_transport_functions = { .lldd_dev_found = asd_dev_found, .lldd_dev_gone = asd_dev_gone, .lldd_execute_task = asd_execute_task, .lldd_abort_task = asd_abort_task, .lldd_abort_task_set = asd_abort_task_set, .lldd_clear_aca = asd_clear_aca, .lldd_clear_task_set = asd_clear_task_set, .lldd_I_T_nexus_reset = asd_I_T_nexus_reset, .lldd_lu_reset = asd_lu_reset, .lldd_query_task = asd_query_task, .lldd_clear_nexus_port = asd_clear_nexus_port, .lldd_clear_nexus_ha = asd_clear_nexus_ha, .lldd_control_phy = asd_control_phy, .lldd_ata_set_dmamode = asd_set_dmamode, }; static const struct pci_device_id aic94xx_pci_table[] = { {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, 0x410),0, 0, 1}, {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, 0x412),0, 0, 1}, {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, 0x416),0, 0, 1}, {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, 0x41E),0, 0, 1}, {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, 0x41F),0, 0, 1}, {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, 0x430),0, 0, 2}, {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, 0x432),0, 0, 2}, {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, 0x43E),0, 0, 2}, {PCI_DEVICE(PCI_VENDOR_ID_ADAPTEC2, 0x43F),0, 0, 2}, {} }; MODULE_DEVICE_TABLE(pci, aic94xx_pci_table); static struct pci_driver aic94xx_pci_driver = { .name = ASD_DRIVER_NAME, .id_table = aic94xx_pci_table, .probe = asd_pci_probe, .remove = asd_pci_remove, }; static int __init aic94xx_init(void) { int err; asd_printk("%s version %s loaded\n", ASD_DRIVER_DESCRIPTION, ASD_DRIVER_VERSION); err = asd_create_global_caches(); if (err) return err; aic94xx_transport_template = sas_domain_attach_transport(&aic94xx_transport_functions); if (!aic94xx_transport_template) goto out_destroy_caches; err = pci_register_driver(&aic94xx_pci_driver); if (err) goto out_release_transport; err = asd_create_driver_attrs(&aic94xx_pci_driver.driver); if (err) goto out_unregister_pcidrv; return err; out_unregister_pcidrv: pci_unregister_driver(&aic94xx_pci_driver); out_release_transport: sas_release_transport(aic94xx_transport_template); out_destroy_caches: asd_destroy_global_caches(); return err; } static void __exit aic94xx_exit(void) { asd_remove_driver_attrs(&aic94xx_pci_driver.driver); pci_unregister_driver(&aic94xx_pci_driver); sas_release_transport(aic94xx_transport_template); asd_release_firmware(); asd_destroy_global_caches(); asd_printk("%s version %s unloaded\n", ASD_DRIVER_DESCRIPTION, ASD_DRIVER_VERSION); } module_init(aic94xx_init); module_exit(aic94xx_exit); MODULE_AUTHOR("Luben Tuikov "); MODULE_DESCRIPTION(ASD_DRIVER_DESCRIPTION); MODULE_LICENSE("GPL v2"); MODULE_VERSION(ASD_DRIVER_VERSION);