11991Sheppo /* 21991Sheppo * CDDL HEADER START 31991Sheppo * 41991Sheppo * The contents of this file are subject to the terms of the 51991Sheppo * Common Development and Distribution License (the "License"). 61991Sheppo * You may not use this file except in compliance with the License. 71991Sheppo * 81991Sheppo * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 91991Sheppo * or http://www.opensolaris.org/os/licensing. 101991Sheppo * See the License for the specific language governing permissions 111991Sheppo * and limitations under the License. 121991Sheppo * 131991Sheppo * When distributing Covered Code, include this CDDL HEADER in each 141991Sheppo * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 151991Sheppo * If applicable, add the following below this CDDL HEADER, with the 161991Sheppo * fields enclosed by brackets "[]" replaced with your own identifying 171991Sheppo * information: Portions Copyright [yyyy] [name of copyright owner] 181991Sheppo * 191991Sheppo * CDDL HEADER END 201991Sheppo */ 211991Sheppo 221991Sheppo /* 231991Sheppo * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 241991Sheppo * Use is subject to license terms. 251991Sheppo */ 261991Sheppo 271991Sheppo #ifndef _LDC_IMPL_H 281991Sheppo #define _LDC_IMPL_H 291991Sheppo 301991Sheppo #pragma ident "%Z%%M% %I% %E% SMI" 311991Sheppo 321991Sheppo #ifdef __cplusplus 331991Sheppo extern "C" { 341991Sheppo #endif 351991Sheppo 361991Sheppo #include <sys/types.h> 371991Sheppo #include <sys/ddi.h> 381991Sheppo #include <sys/sunddi.h> 391991Sheppo #include <sys/ioctl.h> 401991Sheppo 412410Slm66018 /* Memory map table entries */ 422410Slm66018 #define LDC_MTBL_ENTRIES 8192 /* 8 K */ 431991Sheppo 441991Sheppo /* Define LDC Queue info */ 451991Sheppo #define LDC_PACKET_SHIFT 6 462410Slm66018 #define LDC_QUEUE_ENTRIES 512 472410Slm66018 #define LDC_MTU_MSGS 4 481991Sheppo #define LDC_QUEUE_SIZE (LDC_QUEUE_ENTRIES << LDC_PACKET_SHIFT) 492410Slm66018 #define LDC_DEFAULT_MTU (LDC_QUEUE_SIZE / LDC_MTU_MSGS) 501991Sheppo 511991Sheppo /* 521991Sheppo * LDC Reliable mode - initial packet seqid 531991Sheppo * - If peer initiated handshake, RDX should contain init_seqid + 1 541991Sheppo * - If this endpoint initiated handshake first data packet should 551991Sheppo * contain the message init_seqid + 1 561991Sheppo */ 571991Sheppo #define LDC_INIT_SEQID 0x0 581991Sheppo 591991Sheppo /* LDC Message types */ 601991Sheppo #define LDC_CTRL 0x01 /* Control Pkt */ 611991Sheppo #define LDC_DATA 0x02 /* Data Pkt */ 621991Sheppo #define LDC_ERR 0x10 /* Error Pkt */ 631991Sheppo 641991Sheppo /* LDC Message Subtypes */ 651991Sheppo #define LDC_INFO 0x01 /* Control/Data/Error info pkt */ 661991Sheppo #define LDC_ACK 0x02 /* Control/Data ACK */ 671991Sheppo #define LDC_NACK 0x04 /* Control/Data NACK */ 681991Sheppo 691991Sheppo /* LDC Control Messages */ 701991Sheppo #define LDC_VER 0x01 /* Version message */ 711991Sheppo #define LDC_RTS 0x02 /* Request to Send */ 721991Sheppo #define LDC_RTR 0x03 /* Ready To Receive */ 731991Sheppo #define LDC_RDX 0x04 /* Ready for data exchange */ 741991Sheppo 751991Sheppo #define LDC_CTRL_MASK 0x0f /* Mask to read control bits */ 761991Sheppo 771991Sheppo /* LDC Channel Transport State (tstate) */ 781991Sheppo #define TS_TXQ_RDY 0x01 /* allocated TX queue */ 791991Sheppo #define TS_RXQ_RDY 0x02 /* allocated RX queue */ 801991Sheppo #define TS_INIT (TS_TXQ_RDY | TS_RXQ_RDY) 811991Sheppo #define TS_QCONF_RDY 0x04 /* registered queues with HV */ 821991Sheppo #define TS_CNEX_RDY 0x08 /* registered channel with cnex */ 831991Sheppo #define TS_OPEN (TS_INIT | TS_QCONF_RDY | TS_CNEX_RDY) 841991Sheppo #define TS_LINK_READY 0x10 /* both endpts registered Rx queues */ 851991Sheppo #define TS_READY (TS_OPEN | TS_LINK_READY) 861991Sheppo #define TS_VER_DONE 0x20 /* negotiated version */ 871991Sheppo #define TS_VREADY (TS_READY | TS_VER_DONE) 881991Sheppo #define TS_HSHAKE_DONE 0x40 /* completed handshake */ 891991Sheppo #define TS_UP (TS_READY | TS_VER_DONE | TS_HSHAKE_DONE) 901991Sheppo 912793Slm66018 #define TS_IN_RESET 0x100 /* channel is in reset state */ 922793Slm66018 931991Sheppo /* LDC Channel Transport Handshake states */ 942032Slm66018 #define TS_SENT_VER 0x01 /* Sent version */ 952032Slm66018 #define TS_SENT_RTS 0x02 /* Sent RTS */ 962032Slm66018 #define TS_RCVD_RTR 0x04 /* Received RTR */ 972032Slm66018 #define TS_SENT_RDX 0x08 /* Sent RDX */ 982032Slm66018 #define TS_RCVD_VER 0x10 /* Received version */ 992032Slm66018 #define TS_RCVD_RTS 0x20 /* Received RTS */ 1002032Slm66018 #define TS_SENT_RTR 0x40 /* Sent RTR */ 1012032Slm66018 #define TS_RCVD_RDX 0x80 /* Received RDX */ 1021991Sheppo 1032793Slm66018 /* LDC Interrupt State */ 1042793Slm66018 #define LDC_INTR_NONE 0x00 /* No interrupts */ 1052793Slm66018 #define LDC_INTR_ACTIVE 0x01 /* Interrupt being processed */ 1062793Slm66018 #define LDC_INTR_PEND 0x02 /* Interrupt pending */ 1072793Slm66018 1081991Sheppo /* LDC MSG Envelope */ 1091991Sheppo #define LDC_LEN_MASK 0x3F 1101991Sheppo #define LDC_FRAG_MASK 0xC0 1111991Sheppo 1121991Sheppo #define LDC_FRAG_START 0x40 /* frag_info = 0x01 */ 1131991Sheppo #define LDC_FRAG_STOP 0x80 /* frag_info = 0x02 */ 1141991Sheppo #define LDC_FRAG_CONT 0x00 /* frag_info = 0x00 */ 1151991Sheppo 1161991Sheppo /* 1172032Slm66018 * LDC will retry LDC_MAX_RETRIES times when sending or 1182032Slm66018 * receiving data or if the HV returns back EWOULDBLOCK. 1192032Slm66018 * Between each retry it will wait LDC_DELAY usecs. 1201991Sheppo */ 1212032Slm66018 #define LDC_MAX_RETRIES 1000 1222032Slm66018 #define LDC_DELAY 1 1231991Sheppo 124*3151Ssg70180 /* delay(usec) between channel unregister retries in ldc_close() */ 125*3151Ssg70180 #define LDC_CLOSE_DELAY 1 126*3151Ssg70180 1271991Sheppo /* 1281991Sheppo * LDC Version information 1291991Sheppo */ 1301991Sheppo #define LDC_PAYLOAD_VER_OFF 8 /* offset of version in payload */ 1311991Sheppo 1321991Sheppo typedef struct ldc_ver { 1331991Sheppo uint16_t major; 1341991Sheppo uint16_t minor; 1351991Sheppo } ldc_ver_t; 1361991Sheppo 1371991Sheppo /* 1381991Sheppo * Each guest consists of one or more LDC endpoints represented by a ldc_chan 1391991Sheppo * structure. Each ldc_chan structure points to a ldc_mtbl structure that 1401991Sheppo * contains information about the map table associated with this LDC endpoint. 1411991Sheppo * The map table contains the list of pages being shared by this guest over 1421991Sheppo * this endpoint with the guest at the other end of this endpoint. Each LDC 1431991Sheppo * endpoint also points to a list of memory handles used to bind and export 1441991Sheppo * memory segments from this guest. If a memory segment is bound, it points to 1451991Sheppo * a memory segment structure, which inturn consists of an array of ldc_page 1461991Sheppo * structure for all the pages within that segment. Each ldc_page structure 1471991Sheppo * contains information about the shared page and also points to the 1481991Sheppo * corresponding entry in the map table. 1491991Sheppo * 1501991Sheppo * Each LDC endpoint also points to a list of ldc_dring structures that refer 1511991Sheppo * to both imported and exported descriptor rings. If it is a exported 1521991Sheppo * descriptor ring, it then points to memory handle/memseg corresponding to 1531991Sheppo * the region of memory associated with the descriptor ring. 1541991Sheppo * 1551991Sheppo * +----------+ +----------+ +----------+ 1561991Sheppo * | ldc_chan |-->| ldc_chan |-->| ldc_chan |-->.... 1571991Sheppo * +----------+ +----------+ +----------+ 1581991Sheppo * | | | 1591991Sheppo * | | | 1601991Sheppo * | | | +-----------+ +-----------+ 1611991Sheppo * | | +----->| ldc_dring |---->| ldc_dring |---->...... 1621991Sheppo * | | +-----------+ +-----------+ 1631991Sheppo * | | | 1641991Sheppo * | | +----------------------------+ 1651991Sheppo * | | | 1661991Sheppo * | | v 1671991Sheppo * | | +----------+ +----------+ +----------+ 1681991Sheppo * | +----->| ldc_mhdl |---->| ldc_mhdl |---->| ldc_mhdl |---> .... 1691991Sheppo * | +----------+ +----------+ +----------+ 1701991Sheppo * v | | 1711991Sheppo * +----------+ | +------------+ | +------------+ 1721991Sheppo * | ldc_mtbl |--+ +--->| ldc_memseg |-----+ +--->| ldc_memseg | 1731991Sheppo * +----------+ | +------------+ | +------------+ 1741991Sheppo * | | | | | 1751991Sheppo * v v v | v 1761991Sheppo * +--------------+ +----------+ +--------+ | +--------+ 1771991Sheppo * | ldc_mte_slot |<--------| ldc_page | | cookie | | | cookie | 1781991Sheppo * +--------------+ +----------+ +--------+ | +--------+ 1791991Sheppo * | ldc_mte_slot |<--------| ldc_page | | cookie | v 1801991Sheppo * +--------------+ +----------+ +--------+ +----------+ 1811991Sheppo * | ldc_mte_slot |<-----------------------------------| ldc_page | 1821991Sheppo * +--------------+ +----------+ 1831991Sheppo * | ldc_mte_slot | 1841991Sheppo * +--------------+ 1851991Sheppo * | ...... |/ +------------+ 1861991Sheppo * +--------------+ | entry | 1871991Sheppo * | ldc_mte_slot | +------------+ 1881991Sheppo * +--------------+ | inv_cookie | 1891991Sheppo * \ +------------+ 1901991Sheppo * 1911991Sheppo */ 1921991Sheppo 1931991Sheppo /* 1941991Sheppo * Message format of each packet sent over the LDC channel. 1951991Sheppo * Each packet is 64-bytes long. 1961991Sheppo * 1971991Sheppo * Each packet that is sent over LDC can contain either data or acks. 1981991Sheppo * The type will reflect the contents. The len will contain in bytes 1991991Sheppo * the amount of data being sent. In the case of ACKs, the seqid and 2001991Sheppo * data fields will contain the SEQIDs of messages for which ACKs are 2011991Sheppo * being sent. 2021991Sheppo * 2031991Sheppo * Raw pkt format: 2041991Sheppo * 2051991Sheppo * +------------------------------------------------------+ 2061991Sheppo * 0 - 7 | data payload | 2071991Sheppo * +------------------------------------------------------+ 2081991Sheppo * 2091991Sheppo * Unreliable pkt format: 2101991Sheppo * 2111991Sheppo * +------------------------------------------------------+ 2121991Sheppo * 0 | seqid | env | ctrl | stype | type | 2131991Sheppo * +------------------------------------------------------+ 2141991Sheppo * 1 - 7 | data payload | 2151991Sheppo * +------------------------------------------------------+ 2161991Sheppo * 2171991Sheppo * Reliable pkt format: 2181991Sheppo * 2191991Sheppo * +------------------------------------------------------+ 2201991Sheppo * 0 | seqid | env | ctrl | stype | type | 2211991Sheppo * +------------------------------------------------------+ 2221991Sheppo * 1 | ackid | unused | 2231991Sheppo * +------------------------------------------------------+ 2241991Sheppo * 2 - 7 | data payload | 2251991Sheppo * +------------------------------------------------------+ 2261991Sheppo */ 2271991Sheppo 2281991Sheppo typedef struct ldc_msg { 2291991Sheppo union { 2301991Sheppo struct { 2311991Sheppo uint8_t _type; /* Message type */ 2321991Sheppo uint8_t _stype; /* Message subtype */ 2331991Sheppo uint8_t _ctrl; /* Control/Error Message */ 2341991Sheppo uint8_t _env; /* Message Envelope */ 2351991Sheppo uint32_t _seqid; /* Sequence ID */ 2361991Sheppo 2371991Sheppo union { 2381991Sheppo uint8_t _ud[LDC_PAYLOAD_SIZE_UNRELIABLE]; 2391991Sheppo /* Unreliable data payload */ 2401991Sheppo struct { 2411991Sheppo uint32_t _unused; /* unused */ 2421991Sheppo uint32_t _ackid; /* ACK ID */ 2431991Sheppo uint8_t _rd[LDC_PAYLOAD_SIZE_RELIABLE]; 2441991Sheppo /* Reliable data payload */ 2451991Sheppo } _rl; 2461991Sheppo } _data; 2471991Sheppo } _tpkt; 2481991Sheppo 2491991Sheppo uint8_t _raw[LDC_PAYLOAD_SIZE_RAW]; 2501991Sheppo } _pkt; 2511991Sheppo 2521991Sheppo } ldc_msg_t; 2531991Sheppo 2541991Sheppo #define raw _pkt._raw 2551991Sheppo #define type _pkt._tpkt._type 2561991Sheppo #define stype _pkt._tpkt._stype 2571991Sheppo #define ctrl _pkt._tpkt._ctrl 2581991Sheppo #define env _pkt._tpkt._env 2591991Sheppo #define seqid _pkt._tpkt._seqid 2601991Sheppo #define udata _pkt._tpkt._data._ud 2611991Sheppo #define ackid _pkt._tpkt._data._rl._ackid 2621991Sheppo #define rdata _pkt._tpkt._data._rl._rd 2631991Sheppo 2641991Sheppo /* 2651991Sheppo * LDC Map Table Entry (MTE) 2661991Sheppo * 2671991Sheppo * 6 6 1 1 1 2681991Sheppo * |3 0| psz| 3| 1| 0| 9| 8| 7|6|5|4| 0| 2691991Sheppo * +------+--------------------------+----+----+--+--+--+--+-+-+-+-------+ 2701991Sheppo * | rsvd | PFN | 0 | 0 |CW|CR|IW|IR|X|W|R| pgszc | 2711991Sheppo * +------+--------------------------+----+----+--+--+--+--+-+-+-+-------+ 2721991Sheppo * | hv invalidation cookie | 2731991Sheppo * +---------------------------------------------------------------------+ 2741991Sheppo */ 2751991Sheppo typedef union { 2761991Sheppo struct { 2771991Sheppo uint64_t _rsvd2:8, /* <63:56> reserved */ 2781991Sheppo rpfn:43, /* <55:13> real pfn */ 2791991Sheppo _rsvd1:2, /* <12:11> reserved */ 2801991Sheppo cw:1, /* <10> copy write access */ 2811991Sheppo cr:1, /* <9> copy read perm */ 2821991Sheppo iw:1, /* <8> iommu write perm */ 2831991Sheppo ir:1, /* <7> iommu read perm */ 2841991Sheppo x:1, /* <6> execute perm */ 2851991Sheppo w:1, /* <5> write perm */ 2861991Sheppo r:1, /* <4> read perm */ 2871991Sheppo pgszc:4; /* <3:0> pgsz code */ 2881991Sheppo } mte_bit; 2891991Sheppo 2901991Sheppo uint64_t ll; 2911991Sheppo 2921991Sheppo } ldc_mte_t; 2931991Sheppo 2941991Sheppo #define mte_rpfn mte_bit.rpfn 2951991Sheppo #define mte_cw mte_bit.cw 2961991Sheppo #define mte_cr mte_bit.cr 2971991Sheppo #define mte_iw mte_bit.iw 2981991Sheppo #define mte_ir mte_bit.ir 2991991Sheppo #define mte_x mte_bit.x 3001991Sheppo #define mte_w mte_bit.w 3011991Sheppo #define mte_r mte_bit.r 3021991Sheppo #define mte_pgszc mte_bit.pgszc 3031991Sheppo 3041991Sheppo #define MTE_BSZS_SHIFT(sz) ((sz) * 3) 3051991Sheppo #define MTEBYTES(sz) (MMU_PAGESIZE << MTE_BSZS_SHIFT(sz)) 3061991Sheppo #define MTEPAGES(sz) (1 << MTE_BSZS_SHIFT(sz)) 3071991Sheppo #define MTE_PAGE_SHIFT(sz) (MMU_PAGESHIFT + MTE_BSZS_SHIFT(sz)) 3081991Sheppo #define MTE_PAGE_OFFSET(sz) (MTEBYTES(sz) - 1) 3091991Sheppo #define MTE_PAGEMASK(sz) (~MTE_PAGE_OFFSET(sz)) 3101991Sheppo #define MTE_PFNMASK(sz) (~(MTE_PAGE_OFFSET(sz) >> MMU_PAGESHIFT)) 3111991Sheppo 3121991Sheppo /* 3131991Sheppo * LDC Map Table Slot 3141991Sheppo */ 3151991Sheppo typedef struct ldc_mte_slot { 3161991Sheppo ldc_mte_t entry; 3171991Sheppo uint64_t cookie; 3181991Sheppo } ldc_mte_slot_t; 3191991Sheppo 3201991Sheppo /* 3211991Sheppo * LDC Memory Map Table 3221991Sheppo * 3231991Sheppo * Each LDC has a memory map table it uses to list all the pages 3241991Sheppo * it exporting to its peer over the channel. This structure 3251991Sheppo * contains information about the map table and is pointed to 3261991Sheppo * by the ldc_chan structure. 3271991Sheppo */ 3281991Sheppo typedef struct ldc_mtbl { 3291991Sheppo kmutex_t lock; /* Table lock */ 3301991Sheppo size_t size; /* Table size (in bytes) */ 3311991Sheppo uint64_t next_entry; /* Next entry to use */ 3321991Sheppo uint64_t num_entries; /* Num entries in table */ 3331991Sheppo uint64_t num_avail; /* Num of available entries */ 3342793Slm66018 boolean_t contigmem; /* TRUE=Contig mem alloc'd */ 3351991Sheppo ldc_mte_slot_t *table; /* The table itself */ 3361991Sheppo } ldc_mtbl_t; 3371991Sheppo 3381991Sheppo /* 3391991Sheppo * LDC page and memory segment information 3401991Sheppo */ 3411991Sheppo typedef struct ldc_page { 3421991Sheppo uintptr_t raddr; /* Exported page RA */ 3431991Sheppo uint64_t offset; /* Exported page offset */ 3441991Sheppo size_t size; /* Exported page size */ 3451991Sheppo uint64_t index; /* Index in map table */ 3461991Sheppo ldc_mte_slot_t *mte; /* Map table entry */ 3471991Sheppo } ldc_page_t; 3481991Sheppo 3491991Sheppo typedef struct ldc_memseg { 3501991Sheppo caddr_t vaddr; /* Exported segment VA */ 3511991Sheppo uintptr_t raddr; /* Exported segment VA */ 3521991Sheppo size_t size; /* Exported segment size */ 3531991Sheppo uint64_t npages; /* Number of pages */ 3541991Sheppo ldc_page_t *pages; /* Array of exported pages */ 3551991Sheppo uint32_t ncookies; /* Number of cookies */ 3561991Sheppo ldc_mem_cookie_t *cookies; 3571991Sheppo uint64_t next_cookie; /* Index to next cookie */ 3581991Sheppo } ldc_memseg_t; 3591991Sheppo 3601991Sheppo /* 3611991Sheppo * LDC Cookie address format 3621991Sheppo * 3631991Sheppo * 6 6 m+n 3641991Sheppo * |3| 0| | m| 0| 3651991Sheppo * +-+-------+----------+-------------------+-------------------+ 3661991Sheppo * |X| pgszc | rsvd | table_idx | page_offset | 3671991Sheppo * +-+-------+----------+-------------------+-------------------+ 3681991Sheppo */ 3691991Sheppo #define LDC_COOKIE_PGSZC_MASK 0x7 3701991Sheppo #define LDC_COOKIE_PGSZC_SHIFT 60 3711991Sheppo 3721991Sheppo /* 3731991Sheppo * LDC Memory handle 3741991Sheppo */ 3751991Sheppo typedef struct ldc_chan ldc_chan_t; 3761991Sheppo 3771991Sheppo typedef struct ldc_mhdl { 3781991Sheppo kmutex_t lock; /* Mutex for memory handle */ 3791991Sheppo ldc_mstatus_t status; /* Memory map status */ 3801991Sheppo 3811991Sheppo uint8_t mtype; /* Type of sharing */ 3821991Sheppo uint8_t perm; /* Access permissions */ 3831991Sheppo boolean_t myshadow; /* TRUE=alloc'd shadow mem */ 3841991Sheppo 3851991Sheppo ldc_chan_t *ldcp; /* Pointer to channel struct */ 3861991Sheppo ldc_memseg_t *memseg; /* Bound memory segment */ 3871991Sheppo struct ldc_mhdl *next; /* Next memory handle */ 3881991Sheppo } ldc_mhdl_t; 3891991Sheppo 3901991Sheppo /* 3911991Sheppo * LDC Descriptor rings 3921991Sheppo */ 3931991Sheppo 3941991Sheppo typedef struct ldc_dring { 3951991Sheppo kmutex_t lock; /* Desc ring lock */ 3961991Sheppo ldc_mstatus_t status; /* Desc ring status */ 3971991Sheppo 3981991Sheppo uint32_t dsize; /* Descriptor size */ 3991991Sheppo uint32_t length; /* Descriptor ring length */ 4001991Sheppo uint64_t size; /* Desc ring size (in bytes) */ 4011991Sheppo caddr_t base; /* Descriptor ring base addr */ 4021991Sheppo 4031991Sheppo ldc_chan_t *ldcp; /* Pointer to bound channel */ 4041991Sheppo ldc_mem_handle_t mhdl; /* Mem handle to desc ring */ 4051991Sheppo 4061991Sheppo struct ldc_dring *ch_next; /* Next dring in channel */ 4071991Sheppo struct ldc_dring *next; /* Next dring overall */ 4081991Sheppo 4091991Sheppo } ldc_dring_t; 4101991Sheppo 4111991Sheppo 4121991Sheppo /* 4131991Sheppo * Channel specific information is kept in a separate 4141991Sheppo * structure. These are then stored on a array indexed 4151991Sheppo * by the channel number. 4161991Sheppo */ 4171991Sheppo struct ldc_chan { 4181991Sheppo ldc_chan_t *next; /* Next channel */ 4191991Sheppo 4201991Sheppo kmutex_t lock; /* Channel lock */ 4211991Sheppo uint64_t id; /* Channel ID */ 4221991Sheppo ldc_status_t status; /* Channel status */ 4231991Sheppo uint32_t tstate; /* Channel transport state */ 4241991Sheppo uint32_t hstate; /* Channel transport handshake state */ 4251991Sheppo 4261991Sheppo ldc_dev_t devclass; /* Associated device class */ 4271991Sheppo uint64_t devinst; /* Associated device instance */ 4281991Sheppo ldc_mode_t mode; /* Channel mode */ 4291991Sheppo 4302793Slm66018 uint64_t mtu; /* Max TU size */ 4311991Sheppo 4321991Sheppo ldc_ver_t version; /* Channel version */ 4331991Sheppo uint32_t next_vidx; /* Next version to match */ 4341991Sheppo 4351991Sheppo uint_t (*cb)(uint64_t event, caddr_t arg); 4361991Sheppo caddr_t cb_arg; /* Channel callback and arg */ 4371991Sheppo boolean_t cb_inprogress; /* Channel callback in progress */ 4381991Sheppo boolean_t cb_enabled; /* Channel callbacks are enabled */ 4391991Sheppo 4402793Slm66018 uint8_t tx_intr_state; /* Tx interrupt state */ 4412793Slm66018 uint8_t rx_intr_state; /* Rx interrupt state */ 4421991Sheppo 4432336Snarayan kmutex_t tx_lock; /* Transmit lock */ 4441991Sheppo uint64_t tx_q_entries; /* Num entries in transmit queue */ 4451991Sheppo uint64_t tx_q_va; /* Virtual addr of transmit queue */ 4461991Sheppo uint64_t tx_q_ra; /* Real addr of transmit queue */ 4471991Sheppo uint64_t tx_head; /* Tx queue head */ 4481991Sheppo uint64_t tx_ackd_head; /* Tx queue ACKd head (Reliable) */ 4491991Sheppo uint64_t tx_tail; /* Tx queue tail */ 4501991Sheppo 4511991Sheppo uint64_t rx_q_entries; /* Num entries in receive queue */ 4521991Sheppo uint64_t rx_q_va; /* Virtual addr of receive queue */ 4531991Sheppo uint64_t rx_q_ra; /* Real addr of receive queue */ 4541991Sheppo 4551991Sheppo uint64_t link_state; /* Underlying HV channel state */ 4561991Sheppo 4571991Sheppo ldc_mtbl_t *mtbl; /* Memory table used by channel */ 4581991Sheppo ldc_mhdl_t *mhdl_list; /* List of memory handles */ 4591991Sheppo kmutex_t mlist_lock; /* Mem handle list lock */ 4601991Sheppo 4611991Sheppo ldc_dring_t *exp_dring_list; /* Exported desc ring list */ 4621991Sheppo kmutex_t exp_dlist_lock; /* Lock for exported desc ring list */ 4631991Sheppo ldc_dring_t *imp_dring_list; /* Imported desc ring list */ 4641991Sheppo kmutex_t imp_dlist_lock; /* Lock for imported desc ring list */ 4651991Sheppo 4661991Sheppo uint8_t pkt_payload; /* Size of packet payload */ 4671991Sheppo 4681991Sheppo uint32_t last_msg_snt; /* Seqid of last packet sent */ 4691991Sheppo uint32_t last_ack_rcd; /* Seqid of last ACK recd */ 4701991Sheppo uint32_t last_msg_rcd; /* Seqid of last packet received */ 4711991Sheppo 4721991Sheppo uint32_t stream_remains; /* Number of bytes in stream */ 4731991Sheppo /* packet buffer */ 4741991Sheppo uint32_t stream_offset; /* Offset into packet buffer for */ 4751991Sheppo /* next read */ 4761991Sheppo uint8_t *stream_bufferp; /* Stream packet buffer */ 4771991Sheppo 4781991Sheppo int (*read_p)(ldc_chan_t *ldcp, caddr_t bufferp, 4791991Sheppo size_t *sizep); 4801991Sheppo int (*write_p)(ldc_chan_t *ldcp, caddr_t bufferp, 4811991Sheppo size_t *sizep); 4821991Sheppo }; 4831991Sheppo 4841991Sheppo 4851991Sheppo /* 4861991Sheppo * LDC module soft state structure 4871991Sheppo */ 4881991Sheppo typedef struct ldc_soft_state { 4891991Sheppo kmutex_t lock; /* Protects ldc_soft_state_t */ 4901991Sheppo ldc_cnex_t cinfo; /* channel nexus info */ 4911991Sheppo uint64_t channel_count; /* Number of channels */ 4921991Sheppo uint64_t channels_open; /* Number of open channels */ 4931991Sheppo ldc_chan_t *chan_list; /* List of LDC endpoints */ 4941991Sheppo ldc_dring_t *dring_list; /* Descriptor rings (for export) */ 4952531Snarayan 4962531Snarayan kmem_cache_t *memhdl_cache; /* Memory handle cache */ 4972531Snarayan kmem_cache_t *memseg_cache; /* Memory segment cache */ 4981991Sheppo } ldc_soft_state_t; 4991991Sheppo 5001991Sheppo #ifdef __cplusplus 5011991Sheppo } 5021991Sheppo #endif 5031991Sheppo 5041991Sheppo #endif /* _LDC_IMPL_H */ 505