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 41*2410Slm66018 /* Memory map table entries */ 42*2410Slm66018 #define LDC_MTBL_ENTRIES 8192 /* 8 K */ 431991Sheppo 441991Sheppo /* Define LDC Queue info */ 451991Sheppo #define LDC_PACKET_SHIFT 6 46*2410Slm66018 #define LDC_QUEUE_ENTRIES 512 47*2410Slm66018 #define LDC_MTU_MSGS 4 481991Sheppo #define LDC_QUEUE_SIZE (LDC_QUEUE_ENTRIES << LDC_PACKET_SHIFT) 49*2410Slm66018 #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 911991Sheppo /* LDC Channel Transport Handshake states */ 922032Slm66018 #define TS_SENT_VER 0x01 /* Sent version */ 932032Slm66018 #define TS_SENT_RTS 0x02 /* Sent RTS */ 942032Slm66018 #define TS_RCVD_RTR 0x04 /* Received RTR */ 952032Slm66018 #define TS_SENT_RDX 0x08 /* Sent RDX */ 962032Slm66018 #define TS_RCVD_VER 0x10 /* Received version */ 972032Slm66018 #define TS_RCVD_RTS 0x20 /* Received RTS */ 982032Slm66018 #define TS_SENT_RTR 0x40 /* Sent RTR */ 992032Slm66018 #define TS_RCVD_RDX 0x80 /* Received RDX */ 1001991Sheppo 1011991Sheppo /* LDC MSG Envelope */ 1021991Sheppo #define LDC_LEN_MASK 0x3F 1031991Sheppo #define LDC_FRAG_MASK 0xC0 1041991Sheppo 1051991Sheppo #define LDC_FRAG_START 0x40 /* frag_info = 0x01 */ 1061991Sheppo #define LDC_FRAG_STOP 0x80 /* frag_info = 0x02 */ 1071991Sheppo #define LDC_FRAG_CONT 0x00 /* frag_info = 0x00 */ 1081991Sheppo 1091991Sheppo /* 1102032Slm66018 * LDC will retry LDC_MAX_RETRIES times when sending or 1112032Slm66018 * receiving data or if the HV returns back EWOULDBLOCK. 1122032Slm66018 * Between each retry it will wait LDC_DELAY usecs. 1131991Sheppo */ 1142032Slm66018 #define LDC_MAX_RETRIES 1000 1152032Slm66018 #define LDC_DELAY 1 1161991Sheppo 1171991Sheppo /* 1181991Sheppo * LDC Version information 1191991Sheppo */ 1201991Sheppo #define LDC_PAYLOAD_VER_OFF 8 /* offset of version in payload */ 1211991Sheppo 1221991Sheppo typedef struct ldc_ver { 1231991Sheppo uint16_t major; 1241991Sheppo uint16_t minor; 1251991Sheppo } ldc_ver_t; 1261991Sheppo 1271991Sheppo /* 1281991Sheppo * Each guest consists of one or more LDC endpoints represented by a ldc_chan 1291991Sheppo * structure. Each ldc_chan structure points to a ldc_mtbl structure that 1301991Sheppo * contains information about the map table associated with this LDC endpoint. 1311991Sheppo * The map table contains the list of pages being shared by this guest over 1321991Sheppo * this endpoint with the guest at the other end of this endpoint. Each LDC 1331991Sheppo * endpoint also points to a list of memory handles used to bind and export 1341991Sheppo * memory segments from this guest. If a memory segment is bound, it points to 1351991Sheppo * a memory segment structure, which inturn consists of an array of ldc_page 1361991Sheppo * structure for all the pages within that segment. Each ldc_page structure 1371991Sheppo * contains information about the shared page and also points to the 1381991Sheppo * corresponding entry in the map table. 1391991Sheppo * 1401991Sheppo * Each LDC endpoint also points to a list of ldc_dring structures that refer 1411991Sheppo * to both imported and exported descriptor rings. If it is a exported 1421991Sheppo * descriptor ring, it then points to memory handle/memseg corresponding to 1431991Sheppo * the region of memory associated with the descriptor ring. 1441991Sheppo * 1451991Sheppo * +----------+ +----------+ +----------+ 1461991Sheppo * | ldc_chan |-->| ldc_chan |-->| ldc_chan |-->.... 1471991Sheppo * +----------+ +----------+ +----------+ 1481991Sheppo * | | | 1491991Sheppo * | | | 1501991Sheppo * | | | +-----------+ +-----------+ 1511991Sheppo * | | +----->| ldc_dring |---->| ldc_dring |---->...... 1521991Sheppo * | | +-----------+ +-----------+ 1531991Sheppo * | | | 1541991Sheppo * | | +----------------------------+ 1551991Sheppo * | | | 1561991Sheppo * | | v 1571991Sheppo * | | +----------+ +----------+ +----------+ 1581991Sheppo * | +----->| ldc_mhdl |---->| ldc_mhdl |---->| ldc_mhdl |---> .... 1591991Sheppo * | +----------+ +----------+ +----------+ 1601991Sheppo * v | | 1611991Sheppo * +----------+ | +------------+ | +------------+ 1621991Sheppo * | ldc_mtbl |--+ +--->| ldc_memseg |-----+ +--->| ldc_memseg | 1631991Sheppo * +----------+ | +------------+ | +------------+ 1641991Sheppo * | | | | | 1651991Sheppo * v v v | v 1661991Sheppo * +--------------+ +----------+ +--------+ | +--------+ 1671991Sheppo * | ldc_mte_slot |<--------| ldc_page | | cookie | | | cookie | 1681991Sheppo * +--------------+ +----------+ +--------+ | +--------+ 1691991Sheppo * | ldc_mte_slot |<--------| ldc_page | | cookie | v 1701991Sheppo * +--------------+ +----------+ +--------+ +----------+ 1711991Sheppo * | ldc_mte_slot |<-----------------------------------| ldc_page | 1721991Sheppo * +--------------+ +----------+ 1731991Sheppo * | ldc_mte_slot | 1741991Sheppo * +--------------+ 1751991Sheppo * | ...... |/ +------------+ 1761991Sheppo * +--------------+ | entry | 1771991Sheppo * | ldc_mte_slot | +------------+ 1781991Sheppo * +--------------+ | inv_cookie | 1791991Sheppo * \ +------------+ 1801991Sheppo * 1811991Sheppo */ 1821991Sheppo 1831991Sheppo /* 1841991Sheppo * Message format of each packet sent over the LDC channel. 1851991Sheppo * Each packet is 64-bytes long. 1861991Sheppo * 1871991Sheppo * Each packet that is sent over LDC can contain either data or acks. 1881991Sheppo * The type will reflect the contents. The len will contain in bytes 1891991Sheppo * the amount of data being sent. In the case of ACKs, the seqid and 1901991Sheppo * data fields will contain the SEQIDs of messages for which ACKs are 1911991Sheppo * being sent. 1921991Sheppo * 1931991Sheppo * Raw pkt format: 1941991Sheppo * 1951991Sheppo * +------------------------------------------------------+ 1961991Sheppo * 0 - 7 | data payload | 1971991Sheppo * +------------------------------------------------------+ 1981991Sheppo * 1991991Sheppo * Unreliable pkt format: 2001991Sheppo * 2011991Sheppo * +------------------------------------------------------+ 2021991Sheppo * 0 | seqid | env | ctrl | stype | type | 2031991Sheppo * +------------------------------------------------------+ 2041991Sheppo * 1 - 7 | data payload | 2051991Sheppo * +------------------------------------------------------+ 2061991Sheppo * 2071991Sheppo * Reliable pkt format: 2081991Sheppo * 2091991Sheppo * +------------------------------------------------------+ 2101991Sheppo * 0 | seqid | env | ctrl | stype | type | 2111991Sheppo * +------------------------------------------------------+ 2121991Sheppo * 1 | ackid | unused | 2131991Sheppo * +------------------------------------------------------+ 2141991Sheppo * 2 - 7 | data payload | 2151991Sheppo * +------------------------------------------------------+ 2161991Sheppo */ 2171991Sheppo 2181991Sheppo typedef struct ldc_msg { 2191991Sheppo union { 2201991Sheppo struct { 2211991Sheppo uint8_t _type; /* Message type */ 2221991Sheppo uint8_t _stype; /* Message subtype */ 2231991Sheppo uint8_t _ctrl; /* Control/Error Message */ 2241991Sheppo uint8_t _env; /* Message Envelope */ 2251991Sheppo uint32_t _seqid; /* Sequence ID */ 2261991Sheppo 2271991Sheppo union { 2281991Sheppo uint8_t _ud[LDC_PAYLOAD_SIZE_UNRELIABLE]; 2291991Sheppo /* Unreliable data payload */ 2301991Sheppo struct { 2311991Sheppo uint32_t _unused; /* unused */ 2321991Sheppo uint32_t _ackid; /* ACK ID */ 2331991Sheppo uint8_t _rd[LDC_PAYLOAD_SIZE_RELIABLE]; 2341991Sheppo /* Reliable data payload */ 2351991Sheppo } _rl; 2361991Sheppo } _data; 2371991Sheppo } _tpkt; 2381991Sheppo 2391991Sheppo uint8_t _raw[LDC_PAYLOAD_SIZE_RAW]; 2401991Sheppo } _pkt; 2411991Sheppo 2421991Sheppo } ldc_msg_t; 2431991Sheppo 2441991Sheppo #define raw _pkt._raw 2451991Sheppo #define type _pkt._tpkt._type 2461991Sheppo #define stype _pkt._tpkt._stype 2471991Sheppo #define ctrl _pkt._tpkt._ctrl 2481991Sheppo #define env _pkt._tpkt._env 2491991Sheppo #define seqid _pkt._tpkt._seqid 2501991Sheppo #define udata _pkt._tpkt._data._ud 2511991Sheppo #define ackid _pkt._tpkt._data._rl._ackid 2521991Sheppo #define rdata _pkt._tpkt._data._rl._rd 2531991Sheppo 2541991Sheppo /* 2551991Sheppo * LDC Map Table Entry (MTE) 2561991Sheppo * 2571991Sheppo * 6 6 1 1 1 2581991Sheppo * |3 0| psz| 3| 1| 0| 9| 8| 7|6|5|4| 0| 2591991Sheppo * +------+--------------------------+----+----+--+--+--+--+-+-+-+-------+ 2601991Sheppo * | rsvd | PFN | 0 | 0 |CW|CR|IW|IR|X|W|R| pgszc | 2611991Sheppo * +------+--------------------------+----+----+--+--+--+--+-+-+-+-------+ 2621991Sheppo * | hv invalidation cookie | 2631991Sheppo * +---------------------------------------------------------------------+ 2641991Sheppo */ 2651991Sheppo typedef union { 2661991Sheppo struct { 2671991Sheppo uint64_t _rsvd2:8, /* <63:56> reserved */ 2681991Sheppo rpfn:43, /* <55:13> real pfn */ 2691991Sheppo _rsvd1:2, /* <12:11> reserved */ 2701991Sheppo cw:1, /* <10> copy write access */ 2711991Sheppo cr:1, /* <9> copy read perm */ 2721991Sheppo iw:1, /* <8> iommu write perm */ 2731991Sheppo ir:1, /* <7> iommu read perm */ 2741991Sheppo x:1, /* <6> execute perm */ 2751991Sheppo w:1, /* <5> write perm */ 2761991Sheppo r:1, /* <4> read perm */ 2771991Sheppo pgszc:4; /* <3:0> pgsz code */ 2781991Sheppo } mte_bit; 2791991Sheppo 2801991Sheppo uint64_t ll; 2811991Sheppo 2821991Sheppo } ldc_mte_t; 2831991Sheppo 2841991Sheppo #define mte_rpfn mte_bit.rpfn 2851991Sheppo #define mte_cw mte_bit.cw 2861991Sheppo #define mte_cr mte_bit.cr 2871991Sheppo #define mte_iw mte_bit.iw 2881991Sheppo #define mte_ir mte_bit.ir 2891991Sheppo #define mte_x mte_bit.x 2901991Sheppo #define mte_w mte_bit.w 2911991Sheppo #define mte_r mte_bit.r 2921991Sheppo #define mte_pgszc mte_bit.pgszc 2931991Sheppo 2941991Sheppo #define MTE_BSZS_SHIFT(sz) ((sz) * 3) 2951991Sheppo #define MTEBYTES(sz) (MMU_PAGESIZE << MTE_BSZS_SHIFT(sz)) 2961991Sheppo #define MTEPAGES(sz) (1 << MTE_BSZS_SHIFT(sz)) 2971991Sheppo #define MTE_PAGE_SHIFT(sz) (MMU_PAGESHIFT + MTE_BSZS_SHIFT(sz)) 2981991Sheppo #define MTE_PAGE_OFFSET(sz) (MTEBYTES(sz) - 1) 2991991Sheppo #define MTE_PAGEMASK(sz) (~MTE_PAGE_OFFSET(sz)) 3001991Sheppo #define MTE_PFNMASK(sz) (~(MTE_PAGE_OFFSET(sz) >> MMU_PAGESHIFT)) 3011991Sheppo 3021991Sheppo /* 3031991Sheppo * LDC Map Table Slot 3041991Sheppo */ 3051991Sheppo typedef struct ldc_mte_slot { 3061991Sheppo ldc_mte_t entry; 3071991Sheppo uint64_t cookie; 3081991Sheppo } ldc_mte_slot_t; 3091991Sheppo 3101991Sheppo /* 3111991Sheppo * LDC Memory Map Table 3121991Sheppo * 3131991Sheppo * Each LDC has a memory map table it uses to list all the pages 3141991Sheppo * it exporting to its peer over the channel. This structure 3151991Sheppo * contains information about the map table and is pointed to 3161991Sheppo * by the ldc_chan structure. 3171991Sheppo */ 3181991Sheppo typedef struct ldc_mtbl { 3191991Sheppo kmutex_t lock; /* Table lock */ 3201991Sheppo size_t size; /* Table size (in bytes) */ 3211991Sheppo uint64_t next_entry; /* Next entry to use */ 3221991Sheppo uint64_t num_entries; /* Num entries in table */ 3231991Sheppo uint64_t num_avail; /* Num of available entries */ 3241991Sheppo ldc_mte_slot_t *table; /* The table itself */ 3251991Sheppo } ldc_mtbl_t; 3261991Sheppo 3271991Sheppo /* 3281991Sheppo * LDC page and memory segment information 3291991Sheppo */ 3301991Sheppo typedef struct ldc_page { 3311991Sheppo uintptr_t raddr; /* Exported page RA */ 3321991Sheppo uint64_t offset; /* Exported page offset */ 3331991Sheppo size_t size; /* Exported page size */ 3341991Sheppo uint64_t index; /* Index in map table */ 3351991Sheppo ldc_mte_slot_t *mte; /* Map table entry */ 3361991Sheppo } ldc_page_t; 3371991Sheppo 3381991Sheppo typedef struct ldc_memseg { 3391991Sheppo caddr_t vaddr; /* Exported segment VA */ 3401991Sheppo uintptr_t raddr; /* Exported segment VA */ 3411991Sheppo size_t size; /* Exported segment size */ 3421991Sheppo uint64_t npages; /* Number of pages */ 3431991Sheppo ldc_page_t *pages; /* Array of exported pages */ 3441991Sheppo uint32_t ncookies; /* Number of cookies */ 3451991Sheppo ldc_mem_cookie_t *cookies; 3461991Sheppo uint64_t next_cookie; /* Index to next cookie */ 3471991Sheppo } ldc_memseg_t; 3481991Sheppo 3491991Sheppo /* 3501991Sheppo * LDC Cookie address format 3511991Sheppo * 3521991Sheppo * 6 6 m+n 3531991Sheppo * |3| 0| | m| 0| 3541991Sheppo * +-+-------+----------+-------------------+-------------------+ 3551991Sheppo * |X| pgszc | rsvd | table_idx | page_offset | 3561991Sheppo * +-+-------+----------+-------------------+-------------------+ 3571991Sheppo */ 3581991Sheppo #define LDC_COOKIE_PGSZC_MASK 0x7 3591991Sheppo #define LDC_COOKIE_PGSZC_SHIFT 60 3601991Sheppo 3611991Sheppo /* 3621991Sheppo * LDC Memory handle 3631991Sheppo */ 3641991Sheppo typedef struct ldc_chan ldc_chan_t; 3651991Sheppo 3661991Sheppo typedef struct ldc_mhdl { 3671991Sheppo kmutex_t lock; /* Mutex for memory handle */ 3681991Sheppo ldc_mstatus_t status; /* Memory map status */ 3691991Sheppo 3701991Sheppo uint8_t mtype; /* Type of sharing */ 3711991Sheppo uint8_t perm; /* Access permissions */ 3721991Sheppo boolean_t myshadow; /* TRUE=alloc'd shadow mem */ 3731991Sheppo 3741991Sheppo ldc_chan_t *ldcp; /* Pointer to channel struct */ 3751991Sheppo ldc_memseg_t *memseg; /* Bound memory segment */ 3761991Sheppo struct ldc_mhdl *next; /* Next memory handle */ 3771991Sheppo } ldc_mhdl_t; 3781991Sheppo 3791991Sheppo /* 3801991Sheppo * LDC Descriptor rings 3811991Sheppo */ 3821991Sheppo 3831991Sheppo typedef struct ldc_dring { 3841991Sheppo kmutex_t lock; /* Desc ring lock */ 3851991Sheppo ldc_mstatus_t status; /* Desc ring status */ 3861991Sheppo 3871991Sheppo uint32_t dsize; /* Descriptor size */ 3881991Sheppo uint32_t length; /* Descriptor ring length */ 3891991Sheppo uint64_t size; /* Desc ring size (in bytes) */ 3901991Sheppo caddr_t base; /* Descriptor ring base addr */ 3911991Sheppo 3921991Sheppo ldc_chan_t *ldcp; /* Pointer to bound channel */ 3931991Sheppo ldc_mem_handle_t mhdl; /* Mem handle to desc ring */ 3941991Sheppo 3951991Sheppo struct ldc_dring *ch_next; /* Next dring in channel */ 3961991Sheppo struct ldc_dring *next; /* Next dring overall */ 3971991Sheppo 3981991Sheppo } ldc_dring_t; 3991991Sheppo 4001991Sheppo 4011991Sheppo /* 4021991Sheppo * Channel specific information is kept in a separate 4031991Sheppo * structure. These are then stored on a array indexed 4041991Sheppo * by the channel number. 4051991Sheppo */ 4061991Sheppo struct ldc_chan { 4071991Sheppo ldc_chan_t *next; /* Next channel */ 4081991Sheppo 4091991Sheppo kmutex_t lock; /* Channel lock */ 4101991Sheppo uint64_t id; /* Channel ID */ 4111991Sheppo ldc_status_t status; /* Channel status */ 4121991Sheppo uint32_t tstate; /* Channel transport state */ 4131991Sheppo uint32_t hstate; /* Channel transport handshake state */ 4141991Sheppo 4151991Sheppo ldc_dev_t devclass; /* Associated device class */ 4161991Sheppo uint64_t devinst; /* Associated device instance */ 4171991Sheppo ldc_mode_t mode; /* Channel mode */ 4181991Sheppo 4191991Sheppo uint64_t mtu; /* Max TU size (streaming for now) */ 4201991Sheppo 4211991Sheppo ldc_ver_t version; /* Channel version */ 4221991Sheppo uint32_t next_vidx; /* Next version to match */ 4231991Sheppo 4241991Sheppo uint_t (*cb)(uint64_t event, caddr_t arg); 4251991Sheppo caddr_t cb_arg; /* Channel callback and arg */ 4261991Sheppo boolean_t cb_inprogress; /* Channel callback in progress */ 4271991Sheppo boolean_t cb_enabled; /* Channel callbacks are enabled */ 4281991Sheppo 4291991Sheppo boolean_t intr_pending; /* TRUE if interrupts are pending */ 4301991Sheppo 4312336Snarayan kmutex_t tx_lock; /* Transmit lock */ 4321991Sheppo uint64_t tx_q_entries; /* Num entries in transmit queue */ 4331991Sheppo uint64_t tx_q_va; /* Virtual addr of transmit queue */ 4341991Sheppo uint64_t tx_q_ra; /* Real addr of transmit queue */ 4351991Sheppo uint64_t tx_head; /* Tx queue head */ 4361991Sheppo uint64_t tx_ackd_head; /* Tx queue ACKd head (Reliable) */ 4371991Sheppo uint64_t tx_tail; /* Tx queue tail */ 4381991Sheppo 4391991Sheppo uint64_t rx_q_entries; /* Num entries in receive queue */ 4401991Sheppo uint64_t rx_q_va; /* Virtual addr of receive queue */ 4411991Sheppo uint64_t rx_q_ra; /* Real addr of receive queue */ 4421991Sheppo 4431991Sheppo uint64_t link_state; /* Underlying HV channel state */ 4441991Sheppo 4451991Sheppo ldc_mtbl_t *mtbl; /* Memory table used by channel */ 4461991Sheppo ldc_mhdl_t *mhdl_list; /* List of memory handles */ 4471991Sheppo kmutex_t mlist_lock; /* Mem handle list lock */ 4481991Sheppo 4491991Sheppo ldc_dring_t *exp_dring_list; /* Exported desc ring list */ 4501991Sheppo kmutex_t exp_dlist_lock; /* Lock for exported desc ring list */ 4511991Sheppo ldc_dring_t *imp_dring_list; /* Imported desc ring list */ 4521991Sheppo kmutex_t imp_dlist_lock; /* Lock for imported desc ring list */ 4531991Sheppo 4541991Sheppo uint8_t pkt_payload; /* Size of packet payload */ 4551991Sheppo 4561991Sheppo uint32_t last_msg_snt; /* Seqid of last packet sent */ 4571991Sheppo uint32_t last_ack_rcd; /* Seqid of last ACK recd */ 4581991Sheppo uint32_t last_msg_rcd; /* Seqid of last packet received */ 4591991Sheppo 4601991Sheppo uint32_t stream_remains; /* Number of bytes in stream */ 4611991Sheppo /* packet buffer */ 4621991Sheppo uint32_t stream_offset; /* Offset into packet buffer for */ 4631991Sheppo /* next read */ 4641991Sheppo uint8_t *stream_bufferp; /* Stream packet buffer */ 4651991Sheppo 4661991Sheppo int (*read_p)(ldc_chan_t *ldcp, caddr_t bufferp, 4671991Sheppo size_t *sizep); 4681991Sheppo int (*write_p)(ldc_chan_t *ldcp, caddr_t bufferp, 4691991Sheppo size_t *sizep); 4701991Sheppo }; 4711991Sheppo 4721991Sheppo 4731991Sheppo /* 4741991Sheppo * LDC module soft state structure 4751991Sheppo */ 4761991Sheppo typedef struct ldc_soft_state { 4771991Sheppo kmutex_t lock; /* Protects ldc_soft_state_t */ 4781991Sheppo ldc_cnex_t cinfo; /* channel nexus info */ 4791991Sheppo uint64_t channel_count; /* Number of channels */ 4801991Sheppo uint64_t channels_open; /* Number of open channels */ 4811991Sheppo ldc_chan_t *chan_list; /* List of LDC endpoints */ 4821991Sheppo ldc_dring_t *dring_list; /* Descriptor rings (for export) */ 4831991Sheppo } ldc_soft_state_t; 4841991Sheppo 4851991Sheppo #ifdef __cplusplus 4861991Sheppo } 4871991Sheppo #endif 4881991Sheppo 4891991Sheppo #endif /* _LDC_IMPL_H */ 490