1/*
2 * LICENSE NOTICE.
3 *
4 * Use of the Microsoft Windows Rally Development Kit is covered under
5 * the Microsoft Windows Rally Development Kit License Agreement,
6 * which is provided within the Microsoft Windows Rally Development
7 * Kit or at http://www.microsoft.com/whdc/rally/rallykit.mspx. If you
8 * want a license from Microsoft to use the software in the Microsoft
9 * Windows Rally Development Kit, you must (1) complete the designated
10 * "licensee" information in the Windows Rally Development Kit License
11 * Agreement, and (2) sign and return the Agreement AS IS to Microsoft
12 * at the address provided in the Agreement.
13 */
14
15/*
16 * Copyright (c) Microsoft Corporation 2005.  All rights reserved.
17 * This software is provided with NO WARRANTY.
18 */
19
20#ifndef QOS_PROTOCOL_H
21#define QOS_PROTOCOL_H
22
23/* Function (opcode) for demultiplex header */
24typedef enum {
25    Qopcode_InitializeSink       = 0x00,
26    Qopcode_Ready,              /* 0x01 */
27    Qopcode_Probe,              /* 0x02 */
28    Qopcode_Query,              /* 0x03 */
29    Qopcode_QueryResp,          /* 0x04 */
30    Qopcode_Reset,              /* 0x05 */
31    Qopcode_Error,              /* 0x06 */
32    Qopcode_ACK,                /* 0x07 */
33    Qopcode_CounterSnapshot,    /* 0x08 */
34    Qopcode_CounterResult,      /* 0x09 */
35    Qopcode_CounterLease,       /* 0x0A */
36    Qopcode_INVALID		// must be last Qopcode
37} qos_opcode_t;
38
39typedef enum {
40    Qoserror_InsufficientResources = 0x00,
41    Qoserror_Busy,
42    Qoserror_ModerationNotAvailable,
43    Qoserror_INVALID		// must be last Qoserror
44} qos_error_t;
45
46
47static const char * const Qos_errors[] =
48{
49    "",	// Errors start at 1....
50    "QosInsufficientResources",
51    "QosBusy",
52    "QosModerationNotAvailable",
53    "Invalid-Error"
54};
55
56
57static const char * const Qos_opcode_names[] =
58{
59    "QosInitializeSink",
60    "QosReady",
61    "QosProbe",
62    "QosQuery",
63    "QosQueryResp",
64    "QosReset",
65    "QosError",
66    "QosAck",
67    "QosCounterSnapshot",
68    "QosCounterResult",
69    "QosCounterLease",
70    "Invalid-Opcode"
71};
72
73/* The ethernet header with 802.1q tags included */
74typedef struct {
75    etheraddr_t qeh_dst       __attribute__ ((packed));
76    etheraddr_t qeh_src       __attribute__ ((packed));
77    uint16_t    qeh_qtag      __attribute__ ((packed));
78    uint16_t    qeh_ptag      __attribute__ ((packed));
79    uint16_t    qeh_ethertype __attribute__ ((packed));
80} __attribute__ ((packed)) qos_ether_header_t;
81
82typedef struct {
83    uint8_t	qbh_version __attribute__ ((packed));	/* Version */
84    uint8_t	qbh_tos     __attribute__ ((packed));	/* Type of Svc (0=>Discovery, 1=>Quick Disc, 2=> QoS */
85    uint8_t	qbh_resrvd  __attribute__ ((packed));	/* Reserved, must be zero */
86    uint8_t	qbh_opcode  __attribute__ ((packed));	/* qos_opcode_t */
87    etheraddr_t	qbh_realdst __attribute__ ((packed));	/* intended destination */
88    etheraddr_t	qbh_realsrc __attribute__ ((packed));	/* actual source */
89    uint16_t	qbh_seqnum  __attribute__ ((packed));	/* 0 or a valid sequence number */
90} __attribute__ ((packed)) qos_base_header_t;
91
92
93typedef struct {
94    uint8_t	init_intmod_ctrl __attribute__ ((packed));/* 0=> disable; 1=> enable; 0xFF=> use existing */
95} __attribute__ ((packed)) qos_initsink_header_t;
96
97
98typedef struct {
99    uint32_t	rdy_linkspeed  __attribute__ ((packed));	/* units of 100 bits per second */
100    uint64_t	rdy_tstampfreq __attribute__ ((packed));	/* units of ticks per second */
101} __attribute__ ((packed)) qos_ready_header_t;
102
103
104typedef struct {
105    uint64_t	probe_txstamp  __attribute__ ((packed)); /* set by Controller */
106    uint64_t	probe_rxstamp  __attribute__ ((packed)); /* sent as 0; set by Sink when received */
107    uint64_t	probe_rtxstamp __attribute__ ((packed)); /* sent as 0; set by Sink on return (probegap only) */
108    uint8_t	probe_testtype __attribute__ ((packed)); /* 0=> timed probe; 1=> probegap; 2=> probegap-return */
109    uint8_t	probe_pktID    __attribute__ ((packed)); /* Controller cookie */
110    uint8_t	probe_pqval    __attribute__ ((packed)); /* 1st bit==1 => ValueIsValid; next 7 bits are Value for 802.1p field */
111    uint8_t	probe_payload[0] __attribute__ ((packed)); /* indeterminate length; Controller determines, Sink just returns it */
112} __attribute__ ((packed)) qos_probe_header_t;
113
114/* qos_query_header_t is empty. only the base header appears in the msg */
115
116typedef struct {
117    uint16_t	qr_EvtCnt __attribute__ ((packed)); /* count of 18-octet "qosEventDescr_t's" in payload (max = 82) */
118//  qosEventDescr_t	qr_Events[qr_EvtCnt]
119} __attribute__ ((packed)) qos_queryresponse_header_t;
120
121typedef struct {
122    uint64_t	ctrlr_txstamp __attribute__ ((packed));	/* copied from probe_txstamp */
123    uint64_t	sink_rxstamp  __attribute__ ((packed));	/* copied from probe_rxstamp */
124    uint8_t	evt_pktID     __attribute__ ((packed));	/* returning the Controller cookie from probe_pktID */
125    uint8_t	evt_reserved  __attribute__ ((packed));	/* must be zero */
126} __attribute__ ((packed)) qosEventDescr_t;
127
128/* qos_reset_header_t is empty. only the base header appears in the msg */
129
130typedef struct {
131    uint16_t	qe_errcode __attribute__ ((packed));	/* enum is: qos_error_t */
132} __attribute__ ((packed)) qos_error_header_t;
133
134typedef struct {
135    uint16_t	cnt_rqstd __attribute__ ((packed));	/* max # non-sub-sec samples to return */
136} __attribute__ ((packed)) qos_snapshot_header_t;
137
138typedef struct {
139    uint8_t     subsec_span __attribute__ ((packed));
140    uint8_t     byte_scale  __attribute__ ((packed));
141    uint8_t     pkt_scale   __attribute__ ((packed));
142    uint8_t     history_sz  __attribute__ ((packed));
143} __attribute__ ((packed)) qos_counter_hdr;       /* format of QosCounterResult */
144
145typedef struct {
146    uint16_t    bytes_rcvd __attribute__ ((packed));     /* all values stored in NETWORK byte order! */
147    uint16_t    pkts_rcvd  __attribute__ ((packed));
148    uint16_t    bytes_sent __attribute__ ((packed));
149    uint16_t    pkts_sent  __attribute__ ((packed));
150} __attribute__ ((packed)) qos_perf_sample;
151
152#endif /* QOS_PROTOCOL_H */
153