Deleted Added
full compact
scsi_ctl.c (284794) scsi_ctl.c (284798)
1/*-
2 * Copyright (c) 2008, 2009 Silicon Graphics International Corp.
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 * 1. Redistributions of source code must retain the above copyright

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

31 */
32/*
33 * Peripheral driver interface between CAM and CTL (CAM Target Layer).
34 *
35 * Author: Ken Merry <ken@FreeBSD.org>
36 */
37
38#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2008, 2009 Silicon Graphics International Corp.
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 * 1. Redistributions of source code must retain the above copyright

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

31 */
32/*
33 * Peripheral driver interface between CAM and CTL (CAM Target Layer).
34 *
35 * Author: Ken Merry <ken@FreeBSD.org>
36 */
37
38#include <sys/cdefs.h>
39__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/scsi_ctl.c 284794 2015-06-25 07:07:32Z mav $");
39__FBSDID("$FreeBSD: stable/10/sys/cam/ctl/scsi_ctl.c 284798 2015-06-25 07:11:48Z mav $");
40
41#include <sys/param.h>
42#include <sys/queue.h>
43#include <sys/systm.h>
44#include <sys/kernel.h>
45#include <sys/lock.h>
46#include <sys/mutex.h>
47#include <sys/condvar.h>

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

197static periph_dtor_t ctlfecleanup;
198static periph_start_t ctlfestart;
199static void ctlfedone(struct cam_periph *periph,
200 union ccb *done_ccb);
201
202static void ctlfe_onoffline(void *arg, int online);
203static void ctlfe_online(void *arg);
204static void ctlfe_offline(void *arg);
40
41#include <sys/param.h>
42#include <sys/queue.h>
43#include <sys/systm.h>
44#include <sys/kernel.h>
45#include <sys/lock.h>
46#include <sys/mutex.h>
47#include <sys/condvar.h>

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

197static periph_dtor_t ctlfecleanup;
198static periph_start_t ctlfestart;
199static void ctlfedone(struct cam_periph *periph,
200 union ccb *done_ccb);
201
202static void ctlfe_onoffline(void *arg, int online);
203static void ctlfe_online(void *arg);
204static void ctlfe_offline(void *arg);
205static int ctlfe_lun_enable(void *arg, struct ctl_id targ_id,
206 int lun_id);
207static int ctlfe_lun_disable(void *arg, struct ctl_id targ_id,
208 int lun_id);
205static int ctlfe_lun_enable(void *arg, int lun_id);
206static int ctlfe_lun_disable(void *arg, int lun_id);
209static void ctlfe_dump_sim(struct cam_sim *sim);
210static void ctlfe_dump_queue(struct ctlfe_lun_softc *softc);
211static void ctlfe_datamove(union ctl_io *io);
212static void ctlfe_done(union ctl_io *io);
213static void ctlfe_dump(void);
214
215static struct periph_driver ctlfe_driver =
216{

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

1795 xpt_free_path(path);
1796}
1797
1798/*
1799 * This will get called to enable a LUN on every bus that is attached to
1800 * CTL. So we only need to create a path/periph for this particular bus.
1801 */
1802static int
207static void ctlfe_dump_sim(struct cam_sim *sim);
208static void ctlfe_dump_queue(struct ctlfe_lun_softc *softc);
209static void ctlfe_datamove(union ctl_io *io);
210static void ctlfe_done(union ctl_io *io);
211static void ctlfe_dump(void);
212
213static struct periph_driver ctlfe_driver =
214{

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

1793 xpt_free_path(path);
1794}
1795
1796/*
1797 * This will get called to enable a LUN on every bus that is attached to
1798 * CTL. So we only need to create a path/periph for this particular bus.
1799 */
1800static int
1803ctlfe_lun_enable(void *arg, struct ctl_id targ_id, int lun_id)
1801ctlfe_lun_enable(void *arg, int lun_id)
1804{
1805 struct ctlfe_softc *bus_softc;
1806 struct ctlfe_lun_softc *softc;
1807 struct cam_path *path;
1808 struct cam_periph *periph;
1809 cam_status status;
1810
1811 bus_softc = (struct ctlfe_softc *)arg;
1812
1813 status = xpt_create_path(&path, /*periph*/ NULL,
1802{
1803 struct ctlfe_softc *bus_softc;
1804 struct ctlfe_lun_softc *softc;
1805 struct cam_path *path;
1806 struct cam_periph *periph;
1807 cam_status status;
1808
1809 bus_softc = (struct ctlfe_softc *)arg;
1810
1811 status = xpt_create_path(&path, /*periph*/ NULL,
1814 bus_softc->path_id,
1815 targ_id.id, lun_id);
1812 bus_softc->path_id, 0, lun_id);
1816 /* XXX KDM need some way to return status to CTL here? */
1817 if (status != CAM_REQ_CMP) {
1818 printf("%s: could not create path, status %#x\n", __func__,
1819 status);
1820 return (1);
1821 }
1822
1823 softc = malloc(sizeof(*softc), M_CTLFE, M_WAITOK | M_ZERO);

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

1858 return (0);
1859}
1860
1861/*
1862 * This will get called when the user removes a LUN to disable that LUN
1863 * on every bus that is attached to CTL.
1864 */
1865static int
1813 /* XXX KDM need some way to return status to CTL here? */
1814 if (status != CAM_REQ_CMP) {
1815 printf("%s: could not create path, status %#x\n", __func__,
1816 status);
1817 return (1);
1818 }
1819
1820 softc = malloc(sizeof(*softc), M_CTLFE, M_WAITOK | M_ZERO);

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

1855 return (0);
1856}
1857
1858/*
1859 * This will get called when the user removes a LUN to disable that LUN
1860 * on every bus that is attached to CTL.
1861 */
1862static int
1866ctlfe_lun_disable(void *arg, struct ctl_id targ_id, int lun_id)
1863ctlfe_lun_disable(void *arg, int lun_id)
1867{
1868 struct ctlfe_softc *softc;
1869 struct ctlfe_lun_softc *lun_softc;
1870
1871 softc = (struct ctlfe_softc *)arg;
1872
1873 mtx_lock(&softc->lun_softc_mtx);
1874 STAILQ_FOREACH(lun_softc, &softc->lun_softc_list, links) {
1875 struct cam_path *path;
1876
1877 path = lun_softc->periph->path;
1878
1864{
1865 struct ctlfe_softc *softc;
1866 struct ctlfe_lun_softc *lun_softc;
1867
1868 softc = (struct ctlfe_softc *)arg;
1869
1870 mtx_lock(&softc->lun_softc_mtx);
1871 STAILQ_FOREACH(lun_softc, &softc->lun_softc_list, links) {
1872 struct cam_path *path;
1873
1874 path = lun_softc->periph->path;
1875
1879 if ((xpt_path_target_id(path) == targ_id.id)
1876 if ((xpt_path_target_id(path) == 0)
1880 && (xpt_path_lun_id(path) == lun_id)) {
1881 break;
1882 }
1883 }
1884 if (lun_softc == NULL) {
1885 mtx_unlock(&softc->lun_softc_mtx);
1877 && (xpt_path_lun_id(path) == lun_id)) {
1878 break;
1879 }
1880 }
1881 if (lun_softc == NULL) {
1882 mtx_unlock(&softc->lun_softc_mtx);
1886 printf("%s: can't find target %d lun %d\n", __func__,
1887 targ_id.id, lun_id);
1883 printf("%s: can't find lun %d\n", __func__, lun_id);
1888 return (1);
1889 }
1890 cam_periph_acquire(lun_softc->periph);
1891 mtx_unlock(&softc->lun_softc_mtx);
1892
1893 cam_periph_lock(lun_softc->periph);
1894 cam_periph_invalidate(lun_softc->periph);
1895 cam_periph_unlock(lun_softc->periph);

--- 156 unchanged lines hidden ---
1884 return (1);
1885 }
1886 cam_periph_acquire(lun_softc->periph);
1887 mtx_unlock(&softc->lun_softc_mtx);
1888
1889 cam_periph_lock(lun_softc->periph);
1890 cam_periph_invalidate(lun_softc->periph);
1891 cam_periph_unlock(lun_softc->periph);

--- 156 unchanged lines hidden ---