/*-1* Data structures and definitions for SCSI Interface Modules (SIMs).2*3* SPDX-License-Identifier: BSD-2-Clause4*5* Copyright (c) 1997 Justin T. Gibbs.6* All rights reserved.7*8* Redistribution and use in source and binary forms, with or without9* modification, are permitted provided that the following conditions10* are met:11* 1. Redistributions of source code must retain the above copyright12* notice, this list of conditions, and the following disclaimer,13* without modification, immediately at the beginning of the file.14* 2. The name of the author may not be used to endorse or promote products15* derived from this software without specific prior written permission.16*17* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND18* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE19* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE20* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR21* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL22* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS23* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)24* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT25* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY26* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF27* SUCH DAMAGE.28*/2930#ifndef _CAM_CAM_SIM_H31#define _CAM_CAM_SIM_H 13233#ifdef _KERNEL3435/*36* The sim driver creates a sim for each controller. The sim device37* queue is separately created in order to allow resource sharing between38* sims. For instance, a driver may create one sim for each channel of39* a multi-channel controller and use the same queue for each channel.40* In this way, the queue resources are shared across all the channels41* of the multi-channel controller.42*/4344struct cam_sim;45struct cam_devq;4647typedef void (*sim_action_func)(struct cam_sim *sim, union ccb *ccb);48typedef void (*sim_poll_func)(struct cam_sim *sim);4950struct cam_devq * cam_simq_alloc(uint32_t max_sim_transactions);51void cam_simq_free(struct cam_devq *devq);5253struct cam_sim * cam_sim_alloc(sim_action_func sim_action,54sim_poll_func sim_poll,55const char *sim_name,56void *softc,57uint32_t unit,58struct mtx *mtx,59int max_dev_transactions,60int max_tagged_dev_transactions,61struct cam_devq *queue);62void cam_sim_free(struct cam_sim *sim, int free_devq);63void cam_sim_hold(struct cam_sim *sim);64void cam_sim_release(struct cam_sim *sim);6566/* Optional sim attributes may be set with these. */67void cam_sim_set_path(struct cam_sim *sim, uint32_t path_id);6869/* Generically useful offsets into the sim private area */70#define spriv_ptr0 sim_priv.entries[0].ptr71#define spriv_ptr1 sim_priv.entries[1].ptr72#define spriv_field0 sim_priv.entries[0].field73#define spriv_field1 sim_priv.entries[1].field7475/*76* The sim driver should not access anything directly from this77* structure.78*/79struct cam_sim {80sim_action_func sim_action;81sim_poll_func sim_poll;82const char *sim_name;83void *softc;84struct mtx *mtx;85TAILQ_ENTRY(cam_sim) links;86uint32_t path_id;/* The Boot device may set this to 0? */87uint32_t unit_number;88uint32_t bus_id;89int max_tagged_dev_openings;90int max_dev_openings;91uint32_t flags;92struct cam_devq *devq; /* Device Queue to use for this SIM */93int refcount; /* References to the SIM. */94};9596static __inline uint32_t97cam_sim_path(const struct cam_sim *sim)98{99return (sim->path_id);100}101102static __inline const char *103cam_sim_name(const struct cam_sim *sim)104{105return (sim->sim_name);106}107108static __inline void *109cam_sim_softc(const struct cam_sim *sim)110{111return (sim->softc);112}113114static __inline uint32_t115cam_sim_unit(const struct cam_sim *sim)116{117return (sim->unit_number);118}119120static __inline uint32_t121cam_sim_bus(const struct cam_sim *sim)122{123return (sim->bus_id);124}125126static __inline bool127cam_sim_pollable(const struct cam_sim *sim)128{129return (sim->sim_poll != NULL);130}131132#endif /* _KERNEL */133#endif /* _CAM_CAM_SIM_H */134135136