1 /*
2  * Copyright (c) 2012 Pigeon Point Systems.  All Rights Reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistribution of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistribution in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * Neither the name of Pigeon Point Systems nor the names of
16  * contributors may be used to endorse or promote products derived
17  * from this software without specific prior written permission.
18  *
19  * This software is provided "AS IS," without a warranty of any kind.
20  * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
21  * INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
22  * PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED.
23  * PIGEON POINT SYSTEMS ("PPS") AND ITS LICENSORS SHALL NOT BE LIABLE
24  * FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING
25  * OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.  IN NO EVENT WILL
26  * PPS OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA,
27  * OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR
28  * PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF
29  * LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
30  * EVEN IF PPS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
31  */
32 
33 #include <stdint.h>
34 #include <ipmitool/ipmi_intf.h>
35 
36 /* Global HPM.2 defines */
37 #define HPM2_REVISION		0x01
38 #define HPM3_REVISION		0x01
39 #define HPM2_LAN_PARAMS_REV	0x01
40 #define HPM2_SOL_PARAMS_REV	0x01
41 #define HPM3_LAN_PARAMS_REV	0x01
42 /* IPMI defines parameter revision as
43  * MSN = present revision,
44  * LSN = oldest revision parameter is
45  * backward compatible with. */
46 #define LAN_PARAM_REV(x, y)	(((x) << 4) | ((y) & 0xF))
47 
48 /* HPM.2 capabilities */
49 #define HPM2_CAPS_SOL_EXTENSION		0x01
50 #define HPM2_CAPS_PACKET_TRACE		0x02
51 #define HPM2_CAPS_EXT_MANAGEMENT	0x04
52 #define HPM2_CAPS_VERSION_SENSOR	0x08
53 #define HPM2_CAPS_DYNAMIC_SESSIONS	0x10
54 
55 #if HAVE_PRAGMA_PACK
56 # pragma pack(push, 1)
57 #endif
58 
59 /* HPM.2 LAN attach capabilities */
60 struct hpm2_lan_attach_capabilities {
61 	uint8_t hpm2_revision_id;
62 	uint16_t lan_channel_mask;
63 	uint8_t hpm2_caps;
64 	uint8_t hpm2_lan_params_start;
65 	uint8_t hpm2_lan_params_rev;
66 	uint8_t hpm2_sol_params_start;
67 	uint8_t hpm2_sol_params_rev;
68 } ATTRIBUTE_PACKING;
69 
70 /* HPM.2 LAN channel capabilities */
71 struct hpm2_lan_channel_capabilities {
72 	uint8_t capabilities;
73 	uint8_t attach_type;
74 	uint8_t bandwidth_class;
75 	uint16_t max_inbound_pld_size;
76 	uint16_t max_outbound_pld_size;
77 } ATTRIBUTE_PACKING;
78 
79 #if HAVE_PRAGMA_PACK
80 # pragma pack(pop)
81 #endif
82 
83 /* HPM.2 command assignments */
84 #define HPM2_GET_LAN_ATTACH_CAPABILITIES	0x3E
85 
86 extern int hpm2_get_capabilities(struct ipmi_intf * intf,
87 		struct hpm2_lan_attach_capabilities * caps);
88 extern int hpm2_get_lan_channel_capabilities(struct ipmi_intf * intf,
89 		uint8_t hpm2_lan_params_start,
90 		struct hpm2_lan_channel_capabilities * caps);
91 extern int hpm2_detect_max_payload_size(struct ipmi_intf * intf);
92