1/* 2 * Copyright (c) 2014, LSI Corp. 3 * All rights reserved. 4 * Author: Marian Choy 5 * Support: freebsdraid@lsi.com 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 28 unchanged lines hidden (view full) --- 37 * 38 * Send feedback to: <megaraidfbsd@lsi.com> 39 * Mail to: LSI Corporation, 1621 Barber Lane, Milpitas, CA 95035 40 * ATTN: MegaRaid FreeBSD 41 * 42 */ 43 44#include <sys/cdefs.h> |
45__FBSDID("$FreeBSD: head/sys/dev/mrsas/mrsas.c 272737 2014-10-08 09:19:35Z kadesai $"); |
46 47#include <dev/mrsas/mrsas.h> 48#include <dev/mrsas/mrsas_ioctl.h> 49 50#include <cam/cam.h> 51#include <cam/cam_ccb.h> 52 53#include <sys/sysctl.h> --- 6 unchanged lines hidden (view full) --- 60 * Function prototypes 61 */ 62static d_open_t mrsas_open; 63static d_close_t mrsas_close; 64static d_read_t mrsas_read; 65static d_write_t mrsas_write; 66static d_ioctl_t mrsas_ioctl; 67 |
68static struct mrsas_mgmt_info mrsas_mgmt_info; |
69static struct mrsas_ident *mrsas_find_ident(device_t); 70static void mrsas_shutdown_ctlr(struct mrsas_softc *sc, u_int32_t opcode); 71static void mrsas_flush_cache(struct mrsas_softc *sc); 72static void mrsas_reset_reply_desc(struct mrsas_softc *sc); 73static void mrsas_ocr_thread(void *arg); 74static int mrsas_get_map_info(struct mrsas_softc *sc); 75static int mrsas_get_ld_map_info(struct mrsas_softc *sc); 76static int mrsas_sync_map_info(struct mrsas_softc *sc); --- 56 unchanged lines hidden (view full) --- 133 134extern int mrsas_cam_attach(struct mrsas_softc *sc); 135extern void mrsas_cam_detach(struct mrsas_softc *sc); 136extern void mrsas_cmd_done(struct mrsas_softc *sc, struct mrsas_mpt_cmd *cmd); 137extern void mrsas_free_frame(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd); 138extern int mrsas_alloc_mfi_cmds(struct mrsas_softc *sc); 139extern void mrsas_release_mpt_cmd(struct mrsas_mpt_cmd *cmd); 140extern struct mrsas_mpt_cmd *mrsas_get_mpt_cmd(struct mrsas_softc *sc); |
141extern int mrsas_passthru(struct mrsas_softc *sc, void *arg, u_long ioctlCmd); |
142extern uint8_t MR_ValidateMapInfo(struct mrsas_softc *sc); 143extern u_int16_t MR_GetLDTgtId(u_int32_t ld, MR_DRV_RAID_MAP_ALL *map); 144extern MR_LD_RAID *MR_LdRaidGet(u_int32_t ld, MR_DRV_RAID_MAP_ALL *map); 145extern void mrsas_xpt_freeze(struct mrsas_softc *sc); 146extern void mrsas_xpt_release(struct mrsas_softc *sc); 147extern MRSAS_REQUEST_DESCRIPTOR_UNION *mrsas_get_request_desc(struct mrsas_softc *sc, 148 u_int16_t index); 149extern int mrsas_bus_scan_sim(struct mrsas_softc *sc, struct cam_sim *sim); --- 503 unchanged lines hidden (view full) --- 653 dcmd->cmd_status = 0x0; 654 dcmd->sge_count = 1; 655 dcmd->flags = MFI_FRAME_DIR_READ; 656 dcmd->timeout = 0; 657 dcmd->pad_0 = 0; 658 dcmd->data_xfer_len = sizeof(struct mrsas_evt_detail); 659 dcmd->opcode = MR_DCMD_CTRL_EVENT_WAIT; 660 dcmd->mbox.w[0] = seq_num; |
661 sc->last_seq_num = seq_num; |
662 dcmd->mbox.w[1] = curr_aen.word; 663 dcmd->sgl.sge32[0].phys_addr = (u_int32_t) sc->evt_detail_phys_addr; 664 dcmd->sgl.sge32[0].length = sizeof(struct mrsas_evt_detail); 665 666 if (sc->aen_cmd != NULL) { 667 mrsas_release_mfi_cmd(cmd); 668 return 0; 669 } --- 101 unchanged lines hidden (view full) --- 771 atomic_set(&sc->fw_outstanding,0); 772 773 sc->io_cmds_highwater = 0; 774 775 /* Create a /dev entry for this device. */ 776 sc->mrsas_cdev = make_dev(&mrsas_cdevsw, device_get_unit(dev), UID_ROOT, 777 GID_OPERATOR, (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP), "mrsas%u", 778 device_get_unit(dev)); |
779 if (device_get_unit(dev) == 0) 780 make_dev_alias(sc->mrsas_cdev, "megaraid_sas_ioctl_node"); |
781 if (sc->mrsas_cdev) 782 sc->mrsas_cdev->si_drv1 = sc; 783 784 sc->adprecovery = MRSAS_HBA_OPERATIONAL; 785 sc->UnevenSpanSupport = 0; 786 787 /* Initialize Firmware */ 788 if (mrsas_init_fw(sc) != SUCCESS) { --- 25 unchanged lines hidden (view full) --- 814 815 /* Initiate AEN (Asynchronous Event Notification)*/ 816 817 if (mrsas_start_aen(sc)) { 818 printf("Error: start aen failed\n"); 819 goto fail_start_aen; 820 } 821 |
822 /* 823 * Add this controller to mrsas_mgmt_info structure so that it 824 * can be exported to management applications 825 */ 826 if (device_get_unit(dev) == 0) 827 memset(&mrsas_mgmt_info, 0, sizeof(mrsas_mgmt_info)); 828 829 mrsas_mgmt_info.count++; 830 mrsas_mgmt_info.sc_ptr[mrsas_mgmt_info.max_index] = sc; 831 mrsas_mgmt_info.max_index++; 832 |
833 return (0); 834 835fail_start_aen: 836attach_fail_irq: 837 mrsas_teardown_intr(sc); 838attach_fail_cam: 839 mrsas_cam_detach(sc); 840attach_fail_fw: --- 26 unchanged lines hidden (view full) --- 867 */ 868static int mrsas_detach(device_t dev) 869{ 870 struct mrsas_softc *sc; 871 int i = 0; 872 873 sc = device_get_softc(dev); 874 sc->remove_in_progress = 1; |
875 876 /* 877 * Take the instance off the instance array. Note that we will not 878 * decrement the max_index. We let this array be sparse array 879 */ 880 for (i = 0; i < mrsas_mgmt_info.max_index; i++) { 881 if (mrsas_mgmt_info.sc_ptr[i] == sc) { 882 mrsas_mgmt_info.count--; 883 mrsas_mgmt_info.sc_ptr[i] = NULL; 884 break; 885 } 886 } 887 |
888 if(sc->ocr_thread_active) 889 wakeup(&sc->ocr_chan); 890 while(sc->reset_in_progress){ 891 i++; 892 if (!(i % MRSAS_RESET_NOTICE_INTERVAL)) { 893 mrsas_dprint(sc, MRSAS_INFO, 894 "[%2d]waiting for ocr to be finished\n",i); 895 } --- 227 unchanged lines hidden (view full) --- 1123 * appropriate function for processing depending on the command received. 1124 */ 1125static int 1126mrsas_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, d_thread_t *td) 1127{ 1128 struct mrsas_softc *sc; 1129 int ret = 0, i = 0; 1130 |
1131 struct mrsas_iocpacket *user_ioc = (struct mrsas_iocpacket *)arg; 1132 1133 /* get the Host number & the softc from data sent by the Application */ 1134 sc = mrsas_mgmt_info.sc_ptr[user_ioc->host_no]; 1135 1136 if ((mrsas_mgmt_info.max_index == user_ioc->host_no) || (sc == NULL)) { 1137 printf ("Please check the controller number\n"); 1138 if (sc == NULL) 1139 printf ("There is NO such Host no. %d\n", user_ioc->host_no); 1140 1141 return ENOENT; 1142 } 1143 |
1144 if (sc->remove_in_progress) { 1145 mrsas_dprint(sc, MRSAS_INFO, 1146 "Driver remove or shutdown called.\n"); 1147 return ENOENT; 1148 } 1149 1150 mtx_lock_spin(&sc->ioctl_lock); 1151 if (!sc->reset_in_progress) { --- 12 unchanged lines hidden (view full) --- 1164 "OCR to be finished %d\n",i, 1165 sc->ocr_thread_active); 1166 } 1167 pause("mr_ioctl", hz); 1168 } 1169 1170do_ioctl: 1171 switch (cmd) { |
1172 case MRSAS_IOC_FIRMWARE_PASS_THROUGH64: 1173#ifdef COMPAT_FREEBSD32 1174 case MRSAS_IOC_FIRMWARE_PASS_THROUGH32: 1175#endif 1176 ret = mrsas_passthru(sc, (void *)arg, cmd); |
1177 break; 1178 case MRSAS_IOC_SCAN_BUS: 1179 ret = mrsas_bus_scan(sc); 1180 break; |
1181 default: 1182 mrsas_dprint(sc, MRSAS_TRACE, "IOCTL command 0x%lx is not handled\n", cmd); |
1183 } 1184 1185 return (ret); 1186} 1187 1188/** 1189 * mrsas_setup_irq: Set up interrupt. 1190 * input: Adapter instance soft state --- 2627 unchanged lines hidden --- |