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