Deleted Added
full compact
mrsas.c (276753) mrsas.c (282525)
1/*
2 * Copyright (c) 2014, LSI Corp. All rights reserved. Author: Marian Choy
3 * Support: freebsdraid@lsi.com
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *

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

32 * official policies,either expressed or implied, of the FreeBSD Project.
33 *
34 * Send feedback to: <megaraidfbsd@lsi.com> Mail to: LSI Corporation, 1621
35 * Barber Lane, Milpitas, CA 95035 ATTN: MegaRaid FreeBSD
36 *
37 */
38
39#include <sys/cdefs.h>
1/*
2 * Copyright (c) 2014, LSI Corp. All rights reserved. Author: Marian Choy
3 * Support: freebsdraid@lsi.com
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *

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

32 * official policies,either expressed or implied, of the FreeBSD Project.
33 *
34 * Send feedback to: <megaraidfbsd@lsi.com> Mail to: LSI Corporation, 1621
35 * Barber Lane, Milpitas, CA 95035 ATTN: MegaRaid FreeBSD
36 *
37 */
38
39#include <sys/cdefs.h>
40__FBSDID("$FreeBSD: head/sys/dev/mrsas/mrsas.c 276753 2015-01-06 15:41:23Z jhb $");
40__FBSDID("$FreeBSD: head/sys/dev/mrsas/mrsas.c 282525 2015-05-06 10:32:27Z kadesai $");
41
42#include <dev/mrsas/mrsas.h>
43#include <dev/mrsas/mrsas_ioctl.h>
44
45#include <cam/cam.h>
46#include <cam/cam_ccb.h>
47
48#include <sys/sysctl.h>

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

82static int mrsas_complete_cmd(struct mrsas_softc *sc, u_int32_t MSIxIndex);
83static int mrsas_clear_intr(struct mrsas_softc *sc);
84static int
85mrsas_get_ctrl_info(struct mrsas_softc *sc,
86 struct mrsas_ctrl_info *ctrl_info);
87static int
88mrsas_issue_blocked_abort_cmd(struct mrsas_softc *sc,
89 struct mrsas_mfi_cmd *cmd_to_abort);
41
42#include <dev/mrsas/mrsas.h>
43#include <dev/mrsas/mrsas_ioctl.h>
44
45#include <cam/cam.h>
46#include <cam/cam_ccb.h>
47
48#include <sys/sysctl.h>

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

82static int mrsas_complete_cmd(struct mrsas_softc *sc, u_int32_t MSIxIndex);
83static int mrsas_clear_intr(struct mrsas_softc *sc);
84static int
85mrsas_get_ctrl_info(struct mrsas_softc *sc,
86 struct mrsas_ctrl_info *ctrl_info);
87static int
88mrsas_issue_blocked_abort_cmd(struct mrsas_softc *sc,
89 struct mrsas_mfi_cmd *cmd_to_abort);
90static struct mrsas_softc *mrsas_get_softc_instance(struct cdev *dev,
91 u_long cmd, caddr_t arg);
90u_int32_t mrsas_read_reg(struct mrsas_softc *sc, int offset);
91u_int8_t
92mrsas_build_mptmfi_passthru(struct mrsas_softc *sc,
93 struct mrsas_mfi_cmd *mfi_cmd);
94int mrsas_transition_to_ready(struct mrsas_softc *sc, int ocr);
95int mrsas_init_adapter(struct mrsas_softc *sc);
96int mrsas_alloc_mpt_cmds(struct mrsas_softc *sc);
97int mrsas_alloc_ioc_cmd(struct mrsas_softc *sc);

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

1226mrsas_resume(device_t dev)
1227{
1228 struct mrsas_softc *sc;
1229
1230 sc = device_get_softc(dev);
1231 return (0);
1232}
1233
92u_int32_t mrsas_read_reg(struct mrsas_softc *sc, int offset);
93u_int8_t
94mrsas_build_mptmfi_passthru(struct mrsas_softc *sc,
95 struct mrsas_mfi_cmd *mfi_cmd);
96int mrsas_transition_to_ready(struct mrsas_softc *sc, int ocr);
97int mrsas_init_adapter(struct mrsas_softc *sc);
98int mrsas_alloc_mpt_cmds(struct mrsas_softc *sc);
99int mrsas_alloc_ioc_cmd(struct mrsas_softc *sc);

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

1228mrsas_resume(device_t dev)
1229{
1230 struct mrsas_softc *sc;
1231
1232 sc = device_get_softc(dev);
1233 return (0);
1234}
1235
1236/**
1237 * mrsas_get_softc_instance: Find softc instance based on cmd type
1238 *
1239 * This function will return softc instance based on cmd type.
1240 * In some case, application fire ioctl on required management instance and
1241 * do not provide host_no. Use cdev->si_drv1 to get softc instance for those
1242 * case, else get the softc instance from host_no provided by application in
1243 * user data.
1244 */
1245
1246static struct mrsas_softc *
1247mrsas_get_softc_instance(struct cdev *dev, u_long cmd, caddr_t arg)
1248{
1249 struct mrsas_softc *sc = NULL;
1250 struct mrsas_iocpacket *user_ioc = (struct mrsas_iocpacket *)arg;
1251 if (cmd == MRSAS_IOC_GET_PCI_INFO){
1252 sc = dev->si_drv1;
1253 } else {
1254 /* get the Host number & the softc from data sent by the Application */
1255 sc = mrsas_mgmt_info.sc_ptr[user_ioc->host_no];
1256 if ((user_ioc->host_no >= mrsas_mgmt_info.max_index) || (sc == NULL)) {
1257 if (sc == NULL)
1258 mrsas_dprint(sc, MRSAS_FAULT,
1259 "There is no Controller number %d .\n", user_ioc->host_no);
1260 else
1261 mrsas_dprint(sc, MRSAS_FAULT,
1262 "Invalid Controller number %d .\n", user_ioc->host_no);
1263 }
1264 }
1265
1266 return sc;
1267}
1268
1234/*
1235 * mrsas_ioctl: IOCtl commands entry point.
1236 *
1237 * This function is the entry point for IOCtls from the OS. It calls the
1238 * appropriate function for processing depending on the command received.
1239 */
1240static int
1241mrsas_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag,
1242 struct thread *td)
1243{
1244 struct mrsas_softc *sc;
1245 int ret = 0, i = 0;
1269/*
1270 * mrsas_ioctl: IOCtl commands entry point.
1271 *
1272 * This function is the entry point for IOCtls from the OS. It calls the
1273 * appropriate function for processing depending on the command received.
1274 */
1275static int
1276mrsas_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag,
1277 struct thread *td)
1278{
1279 struct mrsas_softc *sc;
1280 int ret = 0, i = 0;
1281 MRSAS_DRV_PCI_INFORMATION *pciDrvInfo;
1246
1282
1247 struct mrsas_iocpacket *user_ioc = (struct mrsas_iocpacket *)arg;
1248
1249 /* get the Host number & the softc from data sent by the Application */
1250 sc = mrsas_mgmt_info.sc_ptr[user_ioc->host_no];
1251
1252 if ((mrsas_mgmt_info.max_index == user_ioc->host_no) || (sc == NULL)) {
1253 printf("Please check the controller number\n");
1254 if (sc == NULL)
1255 printf("There is NO such Host no. %d\n", user_ioc->host_no);
1256
1283 sc = mrsas_get_softc_instance(dev, cmd, arg);
1284 if (!sc)
1257 return ENOENT;
1285 return ENOENT;
1258 }
1286
1259 if (sc->remove_in_progress) {
1260 mrsas_dprint(sc, MRSAS_INFO,
1261 "Driver remove or shutdown called.\n");
1262 return ENOENT;
1263 }
1264 mtx_lock_spin(&sc->ioctl_lock);
1265 if (!sc->reset_in_progress) {
1266 mtx_unlock_spin(&sc->ioctl_lock);

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

1294
1295 /* Increment the Ioctl counting semaphore value */
1296 sema_post(&sc->ioctl_count_sema);
1297
1298 break;
1299 case MRSAS_IOC_SCAN_BUS:
1300 ret = mrsas_bus_scan(sc);
1301 break;
1287 if (sc->remove_in_progress) {
1288 mrsas_dprint(sc, MRSAS_INFO,
1289 "Driver remove or shutdown called.\n");
1290 return ENOENT;
1291 }
1292 mtx_lock_spin(&sc->ioctl_lock);
1293 if (!sc->reset_in_progress) {
1294 mtx_unlock_spin(&sc->ioctl_lock);

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

1322
1323 /* Increment the Ioctl counting semaphore value */
1324 sema_post(&sc->ioctl_count_sema);
1325
1326 break;
1327 case MRSAS_IOC_SCAN_BUS:
1328 ret = mrsas_bus_scan(sc);
1329 break;
1330
1331 case MRSAS_IOC_GET_PCI_INFO:
1332 pciDrvInfo = (MRSAS_DRV_PCI_INFORMATION *)arg;
1333 memset (pciDrvInfo, 0, sizeof(MRSAS_DRV_PCI_INFORMATION));
1334 pciDrvInfo->busNumber = pci_get_bus(sc->mrsas_dev);
1335 pciDrvInfo->deviceNumber = pci_get_slot(sc->mrsas_dev);
1336 pciDrvInfo->functionNumber = pci_get_function(sc->mrsas_dev);
1337 pciDrvInfo->domainID = pci_get_domain(sc->mrsas_dev);
1338 mrsas_dprint (sc, MRSAS_INFO, "pci bus no: %d,"
1339 "pci device no: %d, pci function no: %d,"
1340 "pci domain ID: %d\n",
1341 pciDrvInfo->busNumber, pciDrvInfo->deviceNumber,
1342 pciDrvInfo->functionNumber, pciDrvInfo->domainID);
1343 ret = 0;
1344 break;
1345
1302 default:
1303 mrsas_dprint(sc, MRSAS_TRACE, "IOCTL command 0x%lx is not handled\n", cmd);
1304 ret = ENOENT;
1305 }
1306
1307 return (ret);
1308}
1309

--- 2726 unchanged lines hidden ---
1346 default:
1347 mrsas_dprint(sc, MRSAS_TRACE, "IOCTL command 0x%lx is not handled\n", cmd);
1348 ret = ENOENT;
1349 }
1350
1351 return (ret);
1352}
1353

--- 2726 unchanged lines hidden ---