diff options
author | K. Y. Srinivasan <kys@microsoft.com> | 2012-08-13 13:06:51 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-16 16:48:07 -0400 |
commit | 9b5957803cb444a99275355eb2309b6fecc63c5f (patch) | |
tree | 87a9d2885d7fbce7e5ce90b7cca1b9a871f586e3 | |
parent | 07646d9c0938d40b943c592dd1c6435ab24c4e2f (diff) |
Drivers: hv: Add KVP definitions for IP address injection
Add the necessary definitions for supporting the IP injection functionality.
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: Olaf Hering <olaf@aepfle.de>
Reviewed-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/hv/hv_util.c | 4 | ||||
-rw-r--r-- | include/linux/hyperv.h | 76 | ||||
-rw-r--r-- | tools/hv/hv_kvp_daemon.c | 2 |
3 files changed, 77 insertions, 5 deletions
diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c index d3ac6a40118b..a0667de7a04c 100644 --- a/drivers/hv/hv_util.c +++ b/drivers/hv/hv_util.c | |||
@@ -263,7 +263,7 @@ static int util_probe(struct hv_device *dev, | |||
263 | (struct hv_util_service *)dev_id->driver_data; | 263 | (struct hv_util_service *)dev_id->driver_data; |
264 | int ret; | 264 | int ret; |
265 | 265 | ||
266 | srv->recv_buffer = kmalloc(PAGE_SIZE, GFP_KERNEL); | 266 | srv->recv_buffer = kmalloc(PAGE_SIZE * 2, GFP_KERNEL); |
267 | if (!srv->recv_buffer) | 267 | if (!srv->recv_buffer) |
268 | return -ENOMEM; | 268 | return -ENOMEM; |
269 | if (srv->util_init) { | 269 | if (srv->util_init) { |
@@ -274,7 +274,7 @@ static int util_probe(struct hv_device *dev, | |||
274 | } | 274 | } |
275 | } | 275 | } |
276 | 276 | ||
277 | ret = vmbus_open(dev->channel, 2 * PAGE_SIZE, 2 * PAGE_SIZE, NULL, 0, | 277 | ret = vmbus_open(dev->channel, 4 * PAGE_SIZE, 4 * PAGE_SIZE, NULL, 0, |
278 | srv->util_cb, dev->channel); | 278 | srv->util_cb, dev->channel); |
279 | if (ret) | 279 | if (ret) |
280 | goto error; | 280 | goto error; |
diff --git a/include/linux/hyperv.h b/include/linux/hyperv.h index 68ed7f7e1fc9..11afc4e0849a 100644 --- a/include/linux/hyperv.h +++ b/include/linux/hyperv.h | |||
@@ -122,12 +122,53 @@ | |||
122 | #define REG_U32 4 | 122 | #define REG_U32 4 |
123 | #define REG_U64 8 | 123 | #define REG_U64 8 |
124 | 124 | ||
125 | /* | ||
126 | * As we look at expanding the KVP functionality to include | ||
127 | * IP injection functionality, we need to maintain binary | ||
128 | * compatibility with older daemons. | ||
129 | * | ||
130 | * The KVP opcodes are defined by the host and it was unfortunate | ||
131 | * that I chose to treat the registration operation as part of the | ||
132 | * KVP operations defined by the host. | ||
133 | * Here is the level of compatibility | ||
134 | * (between the user level daemon and the kernel KVP driver) that we | ||
135 | * will implement: | ||
136 | * | ||
137 | * An older daemon will always be supported on a newer driver. | ||
138 | * A given user level daemon will require a minimal version of the | ||
139 | * kernel driver. | ||
140 | * If we cannot handle the version differences, we will fail gracefully | ||
141 | * (this can happen when we have a user level daemon that is more | ||
142 | * advanced than the KVP driver. | ||
143 | * | ||
144 | * We will use values used in this handshake for determining if we have | ||
145 | * workable user level daemon and the kernel driver. We begin by taking the | ||
146 | * registration opcode out of the KVP opcode namespace. We will however, | ||
147 | * maintain compatibility with the existing user-level daemon code. | ||
148 | */ | ||
149 | |||
150 | /* | ||
151 | * Daemon code not supporting IP injection (legacy daemon). | ||
152 | */ | ||
153 | |||
154 | #define KVP_OP_REGISTER 4 | ||
155 | |||
156 | /* | ||
157 | * Daemon code supporting IP injection. | ||
158 | * The KVP opcode field is used to communicate the | ||
159 | * registration information; so define a namespace that | ||
160 | * will be distinct from the host defined KVP opcode. | ||
161 | */ | ||
162 | |||
163 | #define KVP_OP_REGISTER1 100 | ||
164 | |||
125 | enum hv_kvp_exchg_op { | 165 | enum hv_kvp_exchg_op { |
126 | KVP_OP_GET = 0, | 166 | KVP_OP_GET = 0, |
127 | KVP_OP_SET, | 167 | KVP_OP_SET, |
128 | KVP_OP_DELETE, | 168 | KVP_OP_DELETE, |
129 | KVP_OP_ENUMERATE, | 169 | KVP_OP_ENUMERATE, |
130 | KVP_OP_REGISTER, | 170 | KVP_OP_GET_IP_INFO, |
171 | KVP_OP_SET_IP_INFO, | ||
131 | KVP_OP_COUNT /* Number of operations, must be last. */ | 172 | KVP_OP_COUNT /* Number of operations, must be last. */ |
132 | }; | 173 | }; |
133 | 174 | ||
@@ -140,6 +181,26 @@ enum hv_kvp_exchg_pool { | |||
140 | KVP_POOL_COUNT /* Number of pools, must be last. */ | 181 | KVP_POOL_COUNT /* Number of pools, must be last. */ |
141 | }; | 182 | }; |
142 | 183 | ||
184 | #define ADDR_FAMILY_NONE 0x00 | ||
185 | #define ADDR_FAMILY_IPV4 0x01 | ||
186 | #define ADDR_FAMILY_IPV6 0x02 | ||
187 | |||
188 | #define MAX_ADAPTER_ID_SIZE 128 | ||
189 | #define MAX_IP_ADDR_SIZE 1024 | ||
190 | #define MAX_GATEWAY_SIZE 512 | ||
191 | |||
192 | |||
193 | struct hv_kvp_ipaddr_value { | ||
194 | __u16 adapter_id[MAX_ADAPTER_ID_SIZE]; | ||
195 | __u8 addr_family; | ||
196 | __u8 dhcp_enabled; | ||
197 | __u16 ip_addr[MAX_IP_ADDR_SIZE]; | ||
198 | __u16 sub_net[MAX_IP_ADDR_SIZE]; | ||
199 | __u16 gate_way[MAX_GATEWAY_SIZE]; | ||
200 | __u16 dns_addr[MAX_IP_ADDR_SIZE]; | ||
201 | } __attribute__((packed)); | ||
202 | |||
203 | |||
143 | struct hv_kvp_hdr { | 204 | struct hv_kvp_hdr { |
144 | __u8 operation; | 205 | __u8 operation; |
145 | __u8 pool; | 206 | __u8 pool; |
@@ -181,16 +242,26 @@ struct hv_kvp_register { | |||
181 | }; | 242 | }; |
182 | 243 | ||
183 | struct hv_kvp_msg { | 244 | struct hv_kvp_msg { |
184 | struct hv_kvp_hdr kvp_hdr; | 245 | union { |
246 | struct hv_kvp_hdr kvp_hdr; | ||
247 | int error; | ||
248 | }; | ||
185 | union { | 249 | union { |
186 | struct hv_kvp_msg_get kvp_get; | 250 | struct hv_kvp_msg_get kvp_get; |
187 | struct hv_kvp_msg_set kvp_set; | 251 | struct hv_kvp_msg_set kvp_set; |
188 | struct hv_kvp_msg_delete kvp_delete; | 252 | struct hv_kvp_msg_delete kvp_delete; |
189 | struct hv_kvp_msg_enumerate kvp_enum_data; | 253 | struct hv_kvp_msg_enumerate kvp_enum_data; |
254 | struct hv_kvp_ipaddr_value kvp_ip_val; | ||
190 | struct hv_kvp_register kvp_register; | 255 | struct hv_kvp_register kvp_register; |
191 | } body; | 256 | } body; |
192 | } __attribute__((packed)); | 257 | } __attribute__((packed)); |
193 | 258 | ||
259 | struct hv_kvp_ip_msg { | ||
260 | __u8 operation; | ||
261 | __u8 pool; | ||
262 | struct hv_kvp_ipaddr_value kvp_ip_val; | ||
263 | } __attribute__((packed)); | ||
264 | |||
194 | #ifdef __KERNEL__ | 265 | #ifdef __KERNEL__ |
195 | #include <linux/scatterlist.h> | 266 | #include <linux/scatterlist.h> |
196 | #include <linux/list.h> | 267 | #include <linux/list.h> |
@@ -982,6 +1053,7 @@ void vmbus_driver_unregister(struct hv_driver *hv_driver); | |||
982 | #define HV_S_CONT 0x80070103 | 1053 | #define HV_S_CONT 0x80070103 |
983 | #define HV_ERROR_NOT_SUPPORTED 0x80070032 | 1054 | #define HV_ERROR_NOT_SUPPORTED 0x80070032 |
984 | #define HV_ERROR_MACHINE_LOCKED 0x800704F7 | 1055 | #define HV_ERROR_MACHINE_LOCKED 0x800704F7 |
1056 | #define HV_ERROR_DEVICE_NOT_CONNECTED 0x8007048F | ||
985 | 1057 | ||
986 | /* | 1058 | /* |
987 | * While we want to handle util services as regular devices, | 1059 | * While we want to handle util services as regular devices, |
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c index d9834b362943..8fbcf7b3c69d 100644 --- a/tools/hv/hv_kvp_daemon.c +++ b/tools/hv/hv_kvp_daemon.c | |||
@@ -69,7 +69,7 @@ enum key_index { | |||
69 | }; | 69 | }; |
70 | 70 | ||
71 | static char kvp_send_buffer[4096]; | 71 | static char kvp_send_buffer[4096]; |
72 | static char kvp_recv_buffer[4096]; | 72 | static char kvp_recv_buffer[4096 * 2]; |
73 | static struct sockaddr_nl addr; | 73 | static struct sockaddr_nl addr; |
74 | 74 | ||
75 | static char *os_name = ""; | 75 | static char *os_name = ""; |