cam_xpt.c (db7e3af11198d19592e7e6ef827f4817e823d450) cam_xpt.c (8088699f795d34421f429d5539e8e68cbaf3115c)
1/*
2 * Implementation of the Common Access Method Transport (XPT) layer.
3 *
4 * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs.
5 * Copyright (c) 1997, 1998, 1999 Kenneth D. Merry.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

600
601/* Storage for debugging datastructures */
602#ifdef CAMDEBUG
603struct cam_path *cam_dpath;
604u_int32_t cam_dflags;
605u_int32_t cam_debug_delay;
606#endif
607
1/*
2 * Implementation of the Common Access Method Transport (XPT) layer.
3 *
4 * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs.
5 * Copyright (c) 1997, 1998, 1999 Kenneth D. Merry.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

600
601/* Storage for debugging datastructures */
602#ifdef CAMDEBUG
603struct cam_path *cam_dpath;
604u_int32_t cam_dflags;
605u_int32_t cam_debug_delay;
606#endif
607
608/* Pointers to software interrupt handlers */
609struct intrhand *camnet_ih;
610struct intrhand *cambio_ih;
611
608#if defined(CAM_DEBUG_FLAGS) && !defined(CAMDEBUG)
609#error "You must have options CAMDEBUG to use options CAM_DEBUG_FLAGS"
610#endif
611
612/*
613 * In order to enable the CAM_DEBUG_* options, the user must have CAMDEBUG
614 * enabled. Also, the user must have either none, or all of CAM_DEBUG_BUS,
615 * CAM_DEBUG_TARGET, and CAM_DEBUG_LUN specified.

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

688static void xptscandone(struct cam_periph *periph, union ccb *done_ccb);
689static xpt_busfunc_t xptconfigbuscountfunc;
690static xpt_busfunc_t xptconfigfunc;
691static void xpt_config(void *arg);
692static xpt_devicefunc_t xptpassannouncefunc;
693static void xpt_finishconfig(struct cam_periph *periph, union ccb *ccb);
694static void xptaction(struct cam_sim *sim, union ccb *work_ccb);
695static void xptpoll(struct cam_sim *sim);
612#if defined(CAM_DEBUG_FLAGS) && !defined(CAMDEBUG)
613#error "You must have options CAMDEBUG to use options CAM_DEBUG_FLAGS"
614#endif
615
616/*
617 * In order to enable the CAM_DEBUG_* options, the user must have CAMDEBUG
618 * enabled. Also, the user must have either none, or all of CAM_DEBUG_BUS,
619 * CAM_DEBUG_TARGET, and CAM_DEBUG_LUN specified.

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

692static void xptscandone(struct cam_periph *periph, union ccb *done_ccb);
693static xpt_busfunc_t xptconfigbuscountfunc;
694static xpt_busfunc_t xptconfigfunc;
695static void xpt_config(void *arg);
696static xpt_devicefunc_t xptpassannouncefunc;
697static void xpt_finishconfig(struct cam_periph *periph, union ccb *ccb);
698static void xptaction(struct cam_sim *sim, union ccb *work_ccb);
699static void xptpoll(struct cam_sim *sim);
696static swihand_t swi_camnet;
697static swihand_t swi_cambio;
698static void camisr(cam_isrq_t *queue);
700static void camisr(void *);
699#if 0
700static void xptstart(struct cam_periph *periph, union ccb *work_ccb);
701static void xptasync(struct cam_periph *periph,
702 u_int32_t code, cam_path *path);
703#endif
704static dev_match_ret xptbusmatch(struct dev_match_pattern *patterns,
705 int num_patterns, struct cam_eb *bus);
706static dev_match_ret xptdevicematch(struct dev_match_pattern *patterns,

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

1358 xpt_config_hook->ich_func = xpt_config;
1359 if (config_intrhook_establish(xpt_config_hook) != 0) {
1360 free (xpt_config_hook, M_TEMP);
1361 printf("xpt_init: config_intrhook_establish failed "
1362 "- failing attach\n");
1363 }
1364
1365 /* Install our software interrupt handlers */
701#if 0
702static void xptstart(struct cam_periph *periph, union ccb *work_ccb);
703static void xptasync(struct cam_periph *periph,
704 u_int32_t code, cam_path *path);
705#endif
706static dev_match_ret xptbusmatch(struct dev_match_pattern *patterns,
707 int num_patterns, struct cam_eb *bus);
708static dev_match_ret xptdevicematch(struct dev_match_pattern *patterns,

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

1360 xpt_config_hook->ich_func = xpt_config;
1361 if (config_intrhook_establish(xpt_config_hook) != 0) {
1362 free (xpt_config_hook, M_TEMP);
1363 printf("xpt_init: config_intrhook_establish failed "
1364 "- failing attach\n");
1365 }
1366
1367 /* Install our software interrupt handlers */
1366 register_swi(SWI_CAMNET, swi_camnet);
1367 register_swi(SWI_CAMBIO, swi_cambio);
1368 camnet_ih = sinthand_add("camnet", NULL, camisr, &cam_netq,
1369 SWI_CAMNET, 0);
1370 cambio_ih = sinthand_add("cambio", NULL, camisr, &cam_bioq,
1371 SWI_CAMBIO, 0);
1368}
1369
1370static cam_status
1371xptregister(struct cam_periph *periph, void *arg)
1372{
1373 if (periph == NULL) {
1374 printf("xptregister: periph was NULL!!\n");
1375 return(CAM_REQ_CMP_ERR);

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

3395 */
3396 dev->ccbq.devq_openings--;
3397 dev->ccbq.dev_openings--;
3398
3399 while((devq->send_openings <= 0 || dev->ccbq.dev_openings < 0)
3400 && (--timeout > 0)) {
3401 DELAY(1000);
3402 (*(sim->sim_poll))(sim);
1372}
1373
1374static cam_status
1375xptregister(struct cam_periph *periph, void *arg)
1376{
1377 if (periph == NULL) {
1378 printf("xptregister: periph was NULL!!\n");
1379 return(CAM_REQ_CMP_ERR);

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

3399 */
3400 dev->ccbq.devq_openings--;
3401 dev->ccbq.dev_openings--;
3402
3403 while((devq->send_openings <= 0 || dev->ccbq.dev_openings < 0)
3404 && (--timeout > 0)) {
3405 DELAY(1000);
3406 (*(sim->sim_poll))(sim);
3403 swi_camnet();
3404 swi_cambio();
3407 camisr(&cam_netq);
3408 camisr(&cam_bioq);
3405 }
3406
3407 dev->ccbq.devq_openings++;
3408 dev->ccbq.dev_openings++;
3409
3410 if (timeout != 0) {
3411 xpt_action(start_ccb);
3412 while(--timeout > 0) {
3413 (*(sim->sim_poll))(sim);
3409 }
3410
3411 dev->ccbq.devq_openings++;
3412 dev->ccbq.dev_openings++;
3413
3414 if (timeout != 0) {
3415 xpt_action(start_ccb);
3416 while(--timeout > 0) {
3417 (*(sim->sim_poll))(sim);
3414 swi_camnet();
3415 swi_cambio();
3418 camisr(&cam_netq);
3419 camisr(&cam_bioq);
3416 if ((start_ccb->ccb_h.status & CAM_STATUS_MASK)
3417 != CAM_REQ_INPROG)
3418 break;
3419 DELAY(1000);
3420 }
3421 if (timeout == 0) {
3422 /*
3423 * XXX Is it worth adding a sim_timeout entry

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

4522 * Queue up the request for handling by our SWI handler
4523 * any of the "non-immediate" type of ccbs.
4524 */
4525 switch (done_ccb->ccb_h.path->periph->type) {
4526 case CAM_PERIPH_BIO:
4527 TAILQ_INSERT_TAIL(&cam_bioq, &done_ccb->ccb_h,
4528 sim_links.tqe);
4529 done_ccb->ccb_h.pinfo.index = CAM_DONEQ_INDEX;
3420 if ((start_ccb->ccb_h.status & CAM_STATUS_MASK)
3421 != CAM_REQ_INPROG)
3422 break;
3423 DELAY(1000);
3424 }
3425 if (timeout == 0) {
3426 /*
3427 * XXX Is it worth adding a sim_timeout entry

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

4526 * Queue up the request for handling by our SWI handler
4527 * any of the "non-immediate" type of ccbs.
4528 */
4529 switch (done_ccb->ccb_h.path->periph->type) {
4530 case CAM_PERIPH_BIO:
4531 TAILQ_INSERT_TAIL(&cam_bioq, &done_ccb->ccb_h,
4532 sim_links.tqe);
4533 done_ccb->ccb_h.pinfo.index = CAM_DONEQ_INDEX;
4530 setsoftcambio();
4534 sched_swi(cambio_ih, SWI_NOSWITCH);
4531 break;
4532 case CAM_PERIPH_NET:
4533 TAILQ_INSERT_TAIL(&cam_netq, &done_ccb->ccb_h,
4534 sim_links.tqe);
4535 done_ccb->ccb_h.pinfo.index = CAM_DONEQ_INDEX;
4535 break;
4536 case CAM_PERIPH_NET:
4537 TAILQ_INSERT_TAIL(&cam_netq, &done_ccb->ccb_h,
4538 sim_links.tqe);
4539 done_ccb->ccb_h.pinfo.index = CAM_DONEQ_INDEX;
4536 setsoftcamnet();
4540 sched_swi(camnet_ih, SWI_NOSWITCH);
4537 break;
4538 }
4539 }
4540 splx(s);
4541}
4542
4543union ccb *
4544xpt_alloc_ccb()

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

6235 * The xpt as a "controller" has no interrupt sources, so polling
6236 * is a no-op.
6237 */
6238static void
6239xptpoll(struct cam_sim *sim)
6240{
6241}
6242
4541 break;
4542 }
4543 }
4544 splx(s);
4545}
4546
4547union ccb *
4548xpt_alloc_ccb()

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

6239 * The xpt as a "controller" has no interrupt sources, so polling
6240 * is a no-op.
6241 */
6242static void
6243xptpoll(struct cam_sim *sim)
6244{
6245}
6246
6243/*
6244 * Should only be called by the machine interrupt dispatch routines,
6245 * so put these prototypes here instead of in the header.
6246 */
6247
6248static void
6247static void
6249swi_camnet(void)
6248camisr(void *V_queue)
6250{
6249{
6251 camisr(&cam_netq);
6252}
6253
6254static void
6255swi_cambio(void)
6256{
6257 camisr(&cam_bioq);
6258}
6259
6260static void
6261camisr(cam_isrq_t *queue)
6262{
6250 cam_isrq_t *queue = V_queue;
6263 int s;
6264 struct ccb_hdr *ccb_h;
6265
6266 s = splcam();
6267 while ((ccb_h = TAILQ_FIRST(queue)) != NULL) {
6268 int runq;
6269
6270 TAILQ_REMOVE(queue, ccb_h, sim_links.tqe);

--- 90 unchanged lines hidden ---
6251 int s;
6252 struct ccb_hdr *ccb_h;
6253
6254 s = splcam();
6255 while ((ccb_h = TAILQ_FIRST(queue)) != NULL) {
6256 int runq;
6257
6258 TAILQ_REMOVE(queue, ccb_h, sim_links.tqe);

--- 90 unchanged lines hidden ---