mpt.h (153072) | mpt.h (155521) |
---|---|
1/* $FreeBSD: head/sys/dev/mpt/mpt.h 153072 2005-12-04 02:12:43Z ru $ */ | 1/* $FreeBSD: head/sys/dev/mpt/mpt.h 155521 2006-02-11 01:35:29Z mjacob $ */ |
2/*- 3 * Generic defines for LSI '909 FC adapters. 4 * FreeBSD Version. 5 * 6 * Copyright (c) 2000, 2001 by Greg Ansley 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 71 unchanged lines hidden (view full) --- 81#include <sys/malloc.h> 82#include <sys/mutex.h> 83#include <sys/condvar.h> 84#endif 85#include <sys/proc.h> 86#include <sys/bus.h> 87#include <sys/module.h> 88 | 2/*- 3 * Generic defines for LSI '909 FC adapters. 4 * FreeBSD Version. 5 * 6 * Copyright (c) 2000, 2001 by Greg Ansley 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions --- 71 unchanged lines hidden (view full) --- 81#include <sys/malloc.h> 82#include <sys/mutex.h> 83#include <sys/condvar.h> 84#endif 85#include <sys/proc.h> 86#include <sys/bus.h> 87#include <sys/module.h> 88 |
89#include <machine/bus.h> | |
90#include <machine/clock.h> 91#include <machine/cpu.h> 92#include <machine/resource.h> 93 94#include <sys/rman.h> 95 | 89#include <machine/clock.h> 90#include <machine/cpu.h> 91#include <machine/resource.h> 92 93#include <sys/rman.h> 94 |
95#if __FreeBSD_version < 500000 96#include <pci/pcireg.h> 97#include <pci/pcivar.h> 98#else 99#include <dev/pci/pcireg.h> 100#include <dev/pci/pcivar.h> 101#endif 102 103#include <machine/bus.h> |
|
96#include "opt_ddb.h" 97 98/**************************** Register Definitions ****************************/ 99#include <dev/mpt/mpt_reg.h> 100 101/******************************* MPI Definitions ******************************/ 102#include <dev/mpt/mpilib/mpi_type.h> 103#include <dev/mpt/mpilib/mpi.h> --- 138 unchanged lines hidden (view full) --- 242 uint16_t index; /* Index of this entry */ 243 uint16_t IOCStatus; /* Completion status */ 244 union ccb *ccb; /* CAM request */ 245 void *req_vbuf; /* Virtual Address of Entry */ 246 void *sense_vbuf; /* Virtual Address of sense data */ 247 bus_addr_t req_pbuf; /* Physical Address of Entry */ 248 bus_addr_t sense_pbuf; /* Physical Address of sense data */ 249 bus_dmamap_t dmap; /* DMA map for data buffer */ | 104#include "opt_ddb.h" 105 106/**************************** Register Definitions ****************************/ 107#include <dev/mpt/mpt_reg.h> 108 109/******************************* MPI Definitions ******************************/ 110#include <dev/mpt/mpilib/mpi_type.h> 111#include <dev/mpt/mpilib/mpi.h> --- 138 unchanged lines hidden (view full) --- 250 uint16_t index; /* Index of this entry */ 251 uint16_t IOCStatus; /* Completion status */ 252 union ccb *ccb; /* CAM request */ 253 void *req_vbuf; /* Virtual Address of Entry */ 254 void *sense_vbuf; /* Virtual Address of sense data */ 255 bus_addr_t req_pbuf; /* Physical Address of Entry */ 256 bus_addr_t sense_pbuf; /* Physical Address of sense data */ 257 bus_dmamap_t dmap; /* DMA map for data buffer */ |
258 struct req_entry *chain; /* for SGE overallocations */ |
|
250}; 251 252/**************************** Handler Registration ****************************/ 253/* 254 * Global table of registered reply handlers. The 255 * handler is indicated by byte 3 of the request 256 * index submitted to the IOC. This allows the 257 * driver core to perform generic processing without --- 113 unchanged lines hidden (view full) --- 371 device_t dev; 372#if __FreeBSD_version < 500000 373 int mpt_splsaved; 374 uint32_t mpt_islocked; 375#else 376 struct mtx mpt_lock; 377#endif 378 uint32_t mpt_pers_mask; | 259}; 260 261/**************************** Handler Registration ****************************/ 262/* 263 * Global table of registered reply handlers. The 264 * handler is indicated by byte 3 of the request 265 * index submitted to the IOC. This allows the 266 * driver core to perform generic processing without --- 113 unchanged lines hidden (view full) --- 380 device_t dev; 381#if __FreeBSD_version < 500000 382 int mpt_splsaved; 383 uint32_t mpt_islocked; 384#else 385 struct mtx mpt_lock; 386#endif 387 uint32_t mpt_pers_mask; |
379 uint32_t : 15, | 388 uint32_t : 14, 389 is_sas : 1, |
380 raid_mwce_set : 1, 381 getreqwaiter : 1, 382 shutdwn_raid : 1, 383 shutdwn_recovery: 1, 384 unit : 8, 385 outofbeer : 1, 386 mpt_locksetup : 1, 387 disabled : 1, --- 4 unchanged lines hidden (view full) --- 392 393 /* 394 * IOC Facts 395 */ 396 uint16_t mpt_global_credits; 397 uint16_t request_frame_size; 398 uint8_t mpt_max_devices; 399 uint8_t mpt_max_buses; | 390 raid_mwce_set : 1, 391 getreqwaiter : 1, 392 shutdwn_raid : 1, 393 shutdwn_recovery: 1, 394 unit : 8, 395 outofbeer : 1, 396 mpt_locksetup : 1, 397 disabled : 1, --- 4 unchanged lines hidden (view full) --- 402 403 /* 404 * IOC Facts 405 */ 406 uint16_t mpt_global_credits; 407 uint16_t request_frame_size; 408 uint8_t mpt_max_devices; 409 uint8_t mpt_max_buses; |
410 uint8_t ioc_facts_flags; |
|
400 401 /* 402 * Port Facts 403 * XXX - Add multi-port support!. 404 */ 405 uint16_t mpt_ini_id; 406 uint16_t mpt_port_type; 407 uint16_t mpt_proto_flags; --- 73 unchanged lines hidden (view full) --- 481 bus_addr_t reply_phys; /* BusAddr of reply memory */ 482 483 bus_dma_tag_t buffer_dmat; /* DMA tag for buffers */ 484 bus_dma_tag_t request_dmat; /* DMA tag for request memroy */ 485 bus_dmamap_t request_dmap; /* DMA map for request memroy */ 486 uint8_t *request; /* KVA of Request memory */ 487 bus_addr_t request_phys; /* BusADdr of request memory */ 488 | 411 412 /* 413 * Port Facts 414 * XXX - Add multi-port support!. 415 */ 416 uint16_t mpt_ini_id; 417 uint16_t mpt_port_type; 418 uint16_t mpt_proto_flags; --- 73 unchanged lines hidden (view full) --- 492 bus_addr_t reply_phys; /* BusAddr of reply memory */ 493 494 bus_dma_tag_t buffer_dmat; /* DMA tag for buffers */ 495 bus_dma_tag_t request_dmat; /* DMA tag for request memroy */ 496 bus_dmamap_t request_dmap; /* DMA map for request memroy */ 497 uint8_t *request; /* KVA of Request memory */ 498 bus_addr_t request_phys; /* BusADdr of request memory */ 499 |
500 uint32_t max_seg_cnt; /* calculated after IOC facts */ 501 502 /* 503 * Hardware management 504 */ |
|
489 u_int reset_cnt; 490 491 /* 492 * CAM && Software Management 493 */ 494 request_t *request_pool; 495 struct req_queue request_free_list; 496 struct req_queue request_pending_list; --- 156 unchanged lines hidden (view full) --- 653 654static __inline uint32_t 655mpt_pio_read(struct mpt_softc *mpt, int offset) 656{ 657 return (bus_space_read_4(mpt->pci_pio_st, mpt->pci_pio_sh, offset)); 658} 659/*********************** Reply Frame/Request Management ***********************/ 660/* Max MPT Reply we are willing to accept (must be power of 2) */ | 505 u_int reset_cnt; 506 507 /* 508 * CAM && Software Management 509 */ 510 request_t *request_pool; 511 struct req_queue request_free_list; 512 struct req_queue request_pending_list; --- 156 unchanged lines hidden (view full) --- 669 670static __inline uint32_t 671mpt_pio_read(struct mpt_softc *mpt, int offset) 672{ 673 return (bus_space_read_4(mpt->pci_pio_st, mpt->pci_pio_sh, offset)); 674} 675/*********************** Reply Frame/Request Management ***********************/ 676/* Max MPT Reply we are willing to accept (must be power of 2) */ |
661#define MPT_REPLY_SIZE 128 | 677#define MPT_REPLY_SIZE 256 |
662 | 678 |
663#define MPT_MAX_REQUESTS(mpt) ((mpt)->is_fc ? 1024 : 256) 664#define MPT_REQUEST_AREA 512 665#define MPT_SENSE_SIZE 32 /* included in MPT_REQUEST_SIZE */ | 679#define MPT_MAX_REQUESTS(mpt) 512 680#define MPT_REQUEST_AREA 512 681#define MPT_SENSE_SIZE 32 /* included in MPT_REQUEST_AREA */ |
666#define MPT_REQ_MEM_SIZE(mpt) (MPT_MAX_REQUESTS(mpt) * MPT_REQUEST_AREA) 667 668#define MPT_CONTEXT_CB_SHIFT (16) 669#define MPT_CBI(handle) (handle >> MPT_CONTEXT_CB_SHIFT) 670#define MPT_CBI_TO_HID(cbi) ((cbi) << MPT_CONTEXT_CB_SHIFT) 671#define MPT_CONTEXT_TO_CBI(x) \ 672 (((x) >> MPT_CONTEXT_CB_SHIFT) & (MPT_NUM_REPLY_HANDLERS - 1)) 673#define MPT_CONTEXT_REQI_MASK 0xFFFF --- 35 unchanged lines hidden (view full) --- 709mpt_pop_reply_queue(struct mpt_softc *mpt) 710{ 711 return mpt_read(mpt, MPT_OFFSET_REPLY_Q); 712} 713 714void mpt_complete_request_chain(struct mpt_softc *mpt, 715 struct req_queue *chain, u_int iocstatus); 716/************************** Scatter Gather Managment **************************/ | 682#define MPT_REQ_MEM_SIZE(mpt) (MPT_MAX_REQUESTS(mpt) * MPT_REQUEST_AREA) 683 684#define MPT_CONTEXT_CB_SHIFT (16) 685#define MPT_CBI(handle) (handle >> MPT_CONTEXT_CB_SHIFT) 686#define MPT_CBI_TO_HID(cbi) ((cbi) << MPT_CONTEXT_CB_SHIFT) 687#define MPT_CONTEXT_TO_CBI(x) \ 688 (((x) >> MPT_CONTEXT_CB_SHIFT) & (MPT_NUM_REPLY_HANDLERS - 1)) 689#define MPT_CONTEXT_REQI_MASK 0xFFFF --- 35 unchanged lines hidden (view full) --- 725mpt_pop_reply_queue(struct mpt_softc *mpt) 726{ 727 return mpt_read(mpt, MPT_OFFSET_REPLY_Q); 728} 729 730void mpt_complete_request_chain(struct mpt_softc *mpt, 731 struct req_queue *chain, u_int iocstatus); 732/************************** Scatter Gather Managment **************************/ |
717/* 718 * We cannot tell prior to getting IOC facts how big the IOC's request 719 * area is. Because of this we cannot tell at compile time how many 720 * simple SG elements we can fit within an IOC request prior to having 721 * to put in a chain element. 722 * 723 * Experimentally we know that the Ultra4 parts have a 96 byte request 724 * element size and the Fibre Channel units have a 144 byte request 725 * element size. Therefore, if we have 512-32 (== 480) bytes of request 726 * area to play with, we have room for between 3 and 5 request sized 727 * regions- the first of which is the command plus a simple SG list, 728 * the rest of which are chained continuation SG lists. Given that the 729 * normal request we use is 48 bytes w/o the first SG element, we can 730 * assume we have 480-48 == 432 bytes to have simple SG elements and/or 731 * chain elements. If we assume 32 bit addressing, this works out to 732 * 54 SG or chain elements. If we assume 5 chain elements, then we have 733 * a maximum of 49 seperate actual SG segments. 734 */ 735#define MPT_SGL_MAX 49 736 | 733/* MPT_RQSL- size of request frame, in bytes */ |
737#define MPT_RQSL(mpt) (mpt->request_frame_size << 2) | 734#define MPT_RQSL(mpt) (mpt->request_frame_size << 2) |
738#define MPT_NSGL(mpt) (MPT_RQSL(mpt) / sizeof (SGE_SIMPLE32)) | |
739 | 735 |
740#define MPT_NSGL_FIRST(mpt) \ 741 (((mpt->request_frame_size << 2) - \ 742 sizeof (MSG_SCSI_IO_REQUEST) - \ 743 sizeof (SGE_IO_UNION)) / sizeof (SGE_SIMPLE32)) | 736/* MPT_NSGL- how many SG entries can fit in a request frame size */ 737#define MPT_NSGL(mpt) (MPT_RQSL(mpt) / sizeof (SGE_IO_UNION)) |
744 | 738 |
739/* MPT_NRFM- how many request frames can fit in each request alloc we make */ 740#define MPT_NRFM(mpt) (MPT_REQUEST_AREA / MPT_RQSL(mpt)) 741 742/* 743 * MPT_NSGL_FIRST- # of SG elements that can fit after 744 * an I/O request but still within the request frame. 745 * Do this safely based upon SGE_IO_UNION. 746 * 747 * Note that the first element is *within* the SCSI request. 748 */ 749#define MPT_NSGL_FIRST(mpt) \ 750 ((MPT_RQSL(mpt) - sizeof (MSG_SCSI_IO_REQUEST) + sizeof (SGE_IO_UNION)) / \ 751 sizeof (SGE_IO_UNION)) 752 |
|
745/***************************** IOC Initialization *****************************/ 746int mpt_reset(struct mpt_softc *, int /*reinit*/); 747 748/****************************** Debugging/Logging *****************************/ 749typedef struct mpt_decode_entry { 750 char *name; 751 u_int value; 752 u_int mask; --- 5 unchanged lines hidden (view full) --- 758 759enum { 760 MPT_PRT_ALWAYS, 761 MPT_PRT_FATAL, 762 MPT_PRT_ERROR, 763 MPT_PRT_WARN, 764 MPT_PRT_INFO, 765 MPT_PRT_DEBUG, | 753/***************************** IOC Initialization *****************************/ 754int mpt_reset(struct mpt_softc *, int /*reinit*/); 755 756/****************************** Debugging/Logging *****************************/ 757typedef struct mpt_decode_entry { 758 char *name; 759 u_int value; 760 u_int mask; --- 5 unchanged lines hidden (view full) --- 766 767enum { 768 MPT_PRT_ALWAYS, 769 MPT_PRT_FATAL, 770 MPT_PRT_ERROR, 771 MPT_PRT_WARN, 772 MPT_PRT_INFO, 773 MPT_PRT_DEBUG, |
766 MPT_PRT_TRACE | 774 MPT_PRT_TRACE, 775 MPT_PRT_NONE=100 |
767}; 768 769#define mpt_lprt(mpt, level, ...) \ 770do { \ 771 if (level <= (mpt)->verbose) \ 772 mpt_prt(mpt, __VA_ARGS__); \ 773} while (0) 774 --- 70 unchanged lines hidden (view full) --- 845void mpt_print_reply(void *vmsg); 846void mpt_print_db(uint32_t mb); 847void mpt_print_config_reply(void *vmsg); 848char *mpt_ioc_diag(uint32_t diag); 849void mpt_req_state(mpt_req_state_t state); 850void mpt_print_config_request(void *vmsg); 851void mpt_print_request(void *vmsg); 852void mpt_print_scsi_io_request(MSG_SCSI_IO_REQUEST *msg); | 776}; 777 778#define mpt_lprt(mpt, level, ...) \ 779do { \ 780 if (level <= (mpt)->verbose) \ 781 mpt_prt(mpt, __VA_ARGS__); \ 782} while (0) 783 --- 70 unchanged lines hidden (view full) --- 854void mpt_print_reply(void *vmsg); 855void mpt_print_db(uint32_t mb); 856void mpt_print_config_reply(void *vmsg); 857char *mpt_ioc_diag(uint32_t diag); 858void mpt_req_state(mpt_req_state_t state); 859void mpt_print_config_request(void *vmsg); 860void mpt_print_request(void *vmsg); 861void mpt_print_scsi_io_request(MSG_SCSI_IO_REQUEST *msg); |
862void mpt_dump_sgl(SGE_IO_UNION *se, int offset); |
|
853#endif /* _MPT_H_ */ | 863#endif /* _MPT_H_ */ |