Commit 51491167 authored by Linus Walleij's avatar Linus Walleij Committed by David S. Miller

usb/net: rndis: merge command codes

Switch the hyperv filter and rndis gadget driver to use the same command
enumerators as the other drivers and delete the surplus command codes.
Reviewed-by: default avatarHaiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c80174f3
...@@ -129,8 +129,8 @@ static void dump_rndis_message(struct hv_device *hv_dev, ...@@ -129,8 +129,8 @@ static void dump_rndis_message(struct hv_device *hv_dev,
netdev = net_device->ndev; netdev = net_device->ndev;
switch (rndis_msg->ndis_msg_type) { switch (rndis_msg->ndis_msg_type) {
case REMOTE_NDIS_PACKET_MSG: case RNDIS_MSG_PACKET:
netdev_dbg(netdev, "REMOTE_NDIS_PACKET_MSG (len %u, " netdev_dbg(netdev, "RNDIS_MSG_PACKET (len %u, "
"data offset %u data len %u, # oob %u, " "data offset %u data len %u, # oob %u, "
"oob offset %u, oob len %u, pkt offset %u, " "oob offset %u, oob len %u, pkt offset %u, "
"pkt len %u\n", "pkt len %u\n",
...@@ -144,8 +144,8 @@ static void dump_rndis_message(struct hv_device *hv_dev, ...@@ -144,8 +144,8 @@ static void dump_rndis_message(struct hv_device *hv_dev,
rndis_msg->msg.pkt.per_pkt_info_len); rndis_msg->msg.pkt.per_pkt_info_len);
break; break;
case REMOTE_NDIS_INITIALIZE_CMPLT: case RNDIS_MSG_INIT_C:
netdev_dbg(netdev, "REMOTE_NDIS_INITIALIZE_CMPLT " netdev_dbg(netdev, "RNDIS_MSG_INIT_C "
"(len %u, id 0x%x, status 0x%x, major %d, minor %d, " "(len %u, id 0x%x, status 0x%x, major %d, minor %d, "
"device flags %d, max xfer size 0x%x, max pkts %u, " "device flags %d, max xfer size 0x%x, max pkts %u, "
"pkt aligned %u)\n", "pkt aligned %u)\n",
...@@ -162,8 +162,8 @@ static void dump_rndis_message(struct hv_device *hv_dev, ...@@ -162,8 +162,8 @@ static void dump_rndis_message(struct hv_device *hv_dev,
pkt_alignment_factor); pkt_alignment_factor);
break; break;
case REMOTE_NDIS_QUERY_CMPLT: case RNDIS_MSG_QUERY_C:
netdev_dbg(netdev, "REMOTE_NDIS_QUERY_CMPLT " netdev_dbg(netdev, "RNDIS_MSG_QUERY_C "
"(len %u, id 0x%x, status 0x%x, buf len %u, " "(len %u, id 0x%x, status 0x%x, buf len %u, "
"buf offset %u)\n", "buf offset %u)\n",
rndis_msg->msg_len, rndis_msg->msg_len,
...@@ -175,16 +175,16 @@ static void dump_rndis_message(struct hv_device *hv_dev, ...@@ -175,16 +175,16 @@ static void dump_rndis_message(struct hv_device *hv_dev,
info_buf_offset); info_buf_offset);
break; break;
case REMOTE_NDIS_SET_CMPLT: case RNDIS_MSG_SET_C:
netdev_dbg(netdev, netdev_dbg(netdev,
"REMOTE_NDIS_SET_CMPLT (len %u, id 0x%x, status 0x%x)\n", "RNDIS_MSG_SET_C (len %u, id 0x%x, status 0x%x)\n",
rndis_msg->msg_len, rndis_msg->msg_len,
rndis_msg->msg.set_complete.req_id, rndis_msg->msg.set_complete.req_id,
rndis_msg->msg.set_complete.status); rndis_msg->msg.set_complete.status);
break; break;
case REMOTE_NDIS_INDICATE_STATUS_MSG: case RNDIS_MSG_INDICATE:
netdev_dbg(netdev, "REMOTE_NDIS_INDICATE_STATUS_MSG " netdev_dbg(netdev, "RNDIS_MSG_INDICATE "
"(len %u, status 0x%x, buf len %u, buf offset %u)\n", "(len %u, status 0x%x, buf len %u, buf offset %u)\n",
rndis_msg->msg_len, rndis_msg->msg_len,
rndis_msg->msg.indicate_status.status, rndis_msg->msg.indicate_status.status,
...@@ -264,7 +264,7 @@ static void rndis_filter_receive_response(struct rndis_device *dev, ...@@ -264,7 +264,7 @@ static void rndis_filter_receive_response(struct rndis_device *dev,
sizeof(struct rndis_filter_packet)); sizeof(struct rndis_filter_packet));
if (resp->ndis_msg_type == if (resp->ndis_msg_type ==
REMOTE_NDIS_RESET_CMPLT) { RNDIS_MSG_RESET_C) {
/* does not have a request id field */ /* does not have a request id field */
request->response_msg.msg.reset_complete. request->response_msg.msg.reset_complete.
status = RNDIS_STATUS_BUFFER_OVERFLOW; status = RNDIS_STATUS_BUFFER_OVERFLOW;
...@@ -415,19 +415,19 @@ int rndis_filter_receive(struct hv_device *dev, ...@@ -415,19 +415,19 @@ int rndis_filter_receive(struct hv_device *dev,
dump_rndis_message(dev, rndis_msg); dump_rndis_message(dev, rndis_msg);
switch (rndis_msg->ndis_msg_type) { switch (rndis_msg->ndis_msg_type) {
case REMOTE_NDIS_PACKET_MSG: case RNDIS_MSG_PACKET:
/* data msg */ /* data msg */
rndis_filter_receive_data(rndis_dev, rndis_msg, pkt); rndis_filter_receive_data(rndis_dev, rndis_msg, pkt);
break; break;
case REMOTE_NDIS_INITIALIZE_CMPLT: case RNDIS_MSG_INIT_C:
case REMOTE_NDIS_QUERY_CMPLT: case RNDIS_MSG_QUERY_C:
case REMOTE_NDIS_SET_CMPLT: case RNDIS_MSG_SET_C:
/* completion msgs */ /* completion msgs */
rndis_filter_receive_response(rndis_dev, rndis_msg); rndis_filter_receive_response(rndis_dev, rndis_msg);
break; break;
case REMOTE_NDIS_INDICATE_STATUS_MSG: case RNDIS_MSG_INDICATE:
/* notification msgs */ /* notification msgs */
rndis_filter_receive_indicate_status(rndis_dev, rndis_msg); rndis_filter_receive_indicate_status(rndis_dev, rndis_msg);
break; break;
...@@ -456,7 +456,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid, ...@@ -456,7 +456,7 @@ static int rndis_filter_query_device(struct rndis_device *dev, u32 oid,
return -EINVAL; return -EINVAL;
*result_size = 0; *result_size = 0;
request = get_rndis_request(dev, REMOTE_NDIS_QUERY_MSG, request = get_rndis_request(dev, RNDIS_MSG_QUERY,
RNDIS_MESSAGE_SIZE(struct rndis_query_request)); RNDIS_MESSAGE_SIZE(struct rndis_query_request));
if (!request) { if (!request) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -536,7 +536,7 @@ int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter) ...@@ -536,7 +536,7 @@ int rndis_filter_set_packet_filter(struct rndis_device *dev, u32 new_filter)
ndev = dev->net_dev->ndev; ndev = dev->net_dev->ndev;
request = get_rndis_request(dev, REMOTE_NDIS_SET_MSG, request = get_rndis_request(dev, RNDIS_MSG_SET,
RNDIS_MESSAGE_SIZE(struct rndis_set_request) + RNDIS_MESSAGE_SIZE(struct rndis_set_request) +
sizeof(u32)); sizeof(u32));
if (!request) { if (!request) {
...@@ -588,7 +588,7 @@ static int rndis_filter_init_device(struct rndis_device *dev) ...@@ -588,7 +588,7 @@ static int rndis_filter_init_device(struct rndis_device *dev)
u32 status; u32 status;
int ret, t; int ret, t;
request = get_rndis_request(dev, REMOTE_NDIS_INITIALIZE_MSG, request = get_rndis_request(dev, RNDIS_MSG_INIT,
RNDIS_MESSAGE_SIZE(struct rndis_initialize_request)); RNDIS_MESSAGE_SIZE(struct rndis_initialize_request));
if (!request) { if (!request) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -641,7 +641,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev) ...@@ -641,7 +641,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
struct rndis_halt_request *halt; struct rndis_halt_request *halt;
/* Attempt to do a rndis device halt */ /* Attempt to do a rndis device halt */
request = get_rndis_request(dev, REMOTE_NDIS_HALT_MSG, request = get_rndis_request(dev, RNDIS_MSG_HALT,
RNDIS_MESSAGE_SIZE(struct rndis_halt_request)); RNDIS_MESSAGE_SIZE(struct rndis_halt_request));
if (!request) if (!request)
goto cleanup; goto cleanup;
...@@ -805,7 +805,7 @@ int rndis_filter_send(struct hv_device *dev, ...@@ -805,7 +805,7 @@ int rndis_filter_send(struct hv_device *dev,
if (isvlan) if (isvlan)
rndis_msg_size += NDIS_VLAN_PPI_SIZE; rndis_msg_size += NDIS_VLAN_PPI_SIZE;
rndis_msg->ndis_msg_type = REMOTE_NDIS_PACKET_MSG; rndis_msg->ndis_msg_type = RNDIS_MSG_PACKET;
rndis_msg->msg_len = pkt->total_data_buflen + rndis_msg->msg_len = pkt->total_data_buflen +
rndis_msg_size; rndis_msg_size;
......
...@@ -577,7 +577,7 @@ static int rndis_init_response(int configNr, rndis_init_msg_type *buf) ...@@ -577,7 +577,7 @@ static int rndis_init_response(int configNr, rndis_init_msg_type *buf)
return -ENOMEM; return -ENOMEM;
resp = (rndis_init_cmplt_type *)r->buf; resp = (rndis_init_cmplt_type *)r->buf;
resp->MessageType = cpu_to_le32(REMOTE_NDIS_INITIALIZE_CMPLT); resp->MessageType = cpu_to_le32(RNDIS_MSG_INIT_C);
resp->MessageLength = cpu_to_le32(52); resp->MessageLength = cpu_to_le32(52);
resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS); resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
...@@ -621,7 +621,7 @@ static int rndis_query_response(int configNr, rndis_query_msg_type *buf) ...@@ -621,7 +621,7 @@ static int rndis_query_response(int configNr, rndis_query_msg_type *buf)
return -ENOMEM; return -ENOMEM;
resp = (rndis_query_cmplt_type *)r->buf; resp = (rndis_query_cmplt_type *)r->buf;
resp->MessageType = cpu_to_le32(REMOTE_NDIS_QUERY_CMPLT); resp->MessageType = cpu_to_le32(RNDIS_MSG_QUERY_C);
resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
if (gen_ndis_query_resp(configNr, le32_to_cpu(buf->OID), if (gen_ndis_query_resp(configNr, le32_to_cpu(buf->OID),
...@@ -668,7 +668,7 @@ static int rndis_set_response(int configNr, rndis_set_msg_type *buf) ...@@ -668,7 +668,7 @@ static int rndis_set_response(int configNr, rndis_set_msg_type *buf)
pr_debug("\n"); pr_debug("\n");
#endif #endif
resp->MessageType = cpu_to_le32(REMOTE_NDIS_SET_CMPLT); resp->MessageType = cpu_to_le32(RNDIS_MSG_SET_C);
resp->MessageLength = cpu_to_le32(16); resp->MessageLength = cpu_to_le32(16);
resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
if (gen_ndis_set_resp(configNr, le32_to_cpu(buf->OID), if (gen_ndis_set_resp(configNr, le32_to_cpu(buf->OID),
...@@ -692,7 +692,7 @@ static int rndis_reset_response(int configNr, rndis_reset_msg_type *buf) ...@@ -692,7 +692,7 @@ static int rndis_reset_response(int configNr, rndis_reset_msg_type *buf)
return -ENOMEM; return -ENOMEM;
resp = (rndis_reset_cmplt_type *)r->buf; resp = (rndis_reset_cmplt_type *)r->buf;
resp->MessageType = cpu_to_le32(REMOTE_NDIS_RESET_CMPLT); resp->MessageType = cpu_to_le32(RNDIS_MSG_RESET_C);
resp->MessageLength = cpu_to_le32(16); resp->MessageLength = cpu_to_le32(16);
resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS); resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
/* resent information */ /* resent information */
...@@ -716,8 +716,7 @@ static int rndis_keepalive_response(int configNr, ...@@ -716,8 +716,7 @@ static int rndis_keepalive_response(int configNr,
return -ENOMEM; return -ENOMEM;
resp = (rndis_keepalive_cmplt_type *)r->buf; resp = (rndis_keepalive_cmplt_type *)r->buf;
resp->MessageType = cpu_to_le32( resp->MessageType = cpu_to_le32(RNDIS_MSG_KEEPALIVE_C);
REMOTE_NDIS_KEEPALIVE_CMPLT);
resp->MessageLength = cpu_to_le32(16); resp->MessageLength = cpu_to_le32(16);
resp->RequestID = buf->RequestID; /* Still LE in msg buffer */ resp->RequestID = buf->RequestID; /* Still LE in msg buffer */
resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS); resp->Status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
...@@ -745,7 +744,7 @@ static int rndis_indicate_status_msg(int configNr, u32 status) ...@@ -745,7 +744,7 @@ static int rndis_indicate_status_msg(int configNr, u32 status)
return -ENOMEM; return -ENOMEM;
resp = (rndis_indicate_status_msg_type *)r->buf; resp = (rndis_indicate_status_msg_type *)r->buf;
resp->MessageType = cpu_to_le32(REMOTE_NDIS_INDICATE_STATUS_MSG); resp->MessageType = cpu_to_le32(RNDIS_MSG_INDICATE);
resp->MessageLength = cpu_to_le32(20); resp->MessageLength = cpu_to_le32(20);
resp->Status = cpu_to_le32(status); resp->Status = cpu_to_le32(status);
resp->StatusBufferLength = cpu_to_le32(0); resp->StatusBufferLength = cpu_to_le32(0);
...@@ -817,15 +816,15 @@ int rndis_msg_parser(u8 configNr, u8 *buf) ...@@ -817,15 +816,15 @@ int rndis_msg_parser(u8 configNr, u8 *buf)
/* For USB: responses may take up to 10 seconds */ /* For USB: responses may take up to 10 seconds */
switch (MsgType) { switch (MsgType) {
case REMOTE_NDIS_INITIALIZE_MSG: case RNDIS_MSG_INIT:
pr_debug("%s: REMOTE_NDIS_INITIALIZE_MSG\n", pr_debug("%s: RNDIS_MSG_INIT\n",
__func__); __func__);
params->state = RNDIS_INITIALIZED; params->state = RNDIS_INITIALIZED;
return rndis_init_response(configNr, return rndis_init_response(configNr,
(rndis_init_msg_type *)buf); (rndis_init_msg_type *)buf);
case REMOTE_NDIS_HALT_MSG: case RNDIS_MSG_HALT:
pr_debug("%s: REMOTE_NDIS_HALT_MSG\n", pr_debug("%s: RNDIS_MSG_HALT\n",
__func__); __func__);
params->state = RNDIS_UNINITIALIZED; params->state = RNDIS_UNINITIALIZED;
if (params->dev) { if (params->dev) {
...@@ -834,24 +833,24 @@ int rndis_msg_parser(u8 configNr, u8 *buf) ...@@ -834,24 +833,24 @@ int rndis_msg_parser(u8 configNr, u8 *buf)
} }
return 0; return 0;
case REMOTE_NDIS_QUERY_MSG: case RNDIS_MSG_QUERY:
return rndis_query_response(configNr, return rndis_query_response(configNr,
(rndis_query_msg_type *)buf); (rndis_query_msg_type *)buf);
case REMOTE_NDIS_SET_MSG: case RNDIS_MSG_SET:
return rndis_set_response(configNr, return rndis_set_response(configNr,
(rndis_set_msg_type *)buf); (rndis_set_msg_type *)buf);
case REMOTE_NDIS_RESET_MSG: case RNDIS_MSG_RESET:
pr_debug("%s: REMOTE_NDIS_RESET_MSG\n", pr_debug("%s: RNDIS_MSG_RESET\n",
__func__); __func__);
return rndis_reset_response(configNr, return rndis_reset_response(configNr,
(rndis_reset_msg_type *)buf); (rndis_reset_msg_type *)buf);
case REMOTE_NDIS_KEEPALIVE_MSG: case RNDIS_MSG_KEEPALIVE:
/* For USB: host does this every 5 seconds */ /* For USB: host does this every 5 seconds */
if (rndis_debug > 1) if (rndis_debug > 1)
pr_debug("%s: REMOTE_NDIS_KEEPALIVE_MSG\n", pr_debug("%s: RNDIS_MSG_KEEPALIVE\n",
__func__); __func__);
return rndis_keepalive_response(configNr, return rndis_keepalive_response(configNr,
(rndis_keepalive_msg_type *) (rndis_keepalive_msg_type *)
...@@ -963,7 +962,7 @@ void rndis_add_hdr(struct sk_buff *skb) ...@@ -963,7 +962,7 @@ void rndis_add_hdr(struct sk_buff *skb)
return; return;
header = (void *)skb_push(skb, sizeof(*header)); header = (void *)skb_push(skb, sizeof(*header));
memset(header, 0, sizeof *header); memset(header, 0, sizeof *header);
header->MessageType = cpu_to_le32(REMOTE_NDIS_PACKET_MSG); header->MessageType = cpu_to_le32(RNDIS_MSG_PACKET);
header->MessageLength = cpu_to_le32(skb->len); header->MessageLength = cpu_to_le32(skb->len);
header->DataOffset = cpu_to_le32(36); header->DataOffset = cpu_to_le32(36);
header->DataLength = cpu_to_le32(skb->len - sizeof(*header)); header->DataLength = cpu_to_le32(skb->len - sizeof(*header));
...@@ -1031,7 +1030,7 @@ int rndis_rm_hdr(struct gether *port, ...@@ -1031,7 +1030,7 @@ int rndis_rm_hdr(struct gether *port,
__le32 *tmp = (void *)skb->data; __le32 *tmp = (void *)skb->data;
/* MessageType, MessageLength */ /* MessageType, MessageLength */
if (cpu_to_le32(REMOTE_NDIS_PACKET_MSG) if (cpu_to_le32(RNDIS_MSG_PACKET)
!= get_unaligned(tmp++)) { != get_unaligned(tmp++)) {
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
return -EINVAL; return -EINVAL;
......
...@@ -199,23 +199,6 @@ ...@@ -199,23 +199,6 @@
#define RNDIS_MAJOR_VERSION 0x00000001 #define RNDIS_MAJOR_VERSION 0x00000001
#define RNDIS_MINOR_VERSION 0x00000000 #define RNDIS_MINOR_VERSION 0x00000000
/* Message Set for Connectionless (802.3) Devices */
#define REMOTE_NDIS_PACKET_MSG 0x00000001U
#define REMOTE_NDIS_INITIALIZE_MSG 0x00000002U /* Initialize device */
#define REMOTE_NDIS_HALT_MSG 0x00000003U
#define REMOTE_NDIS_QUERY_MSG 0x00000004U
#define REMOTE_NDIS_SET_MSG 0x00000005U
#define REMOTE_NDIS_RESET_MSG 0x00000006U
#define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007U
#define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008U
/* Message completion */
#define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002U
#define REMOTE_NDIS_QUERY_CMPLT 0x80000004U
#define REMOTE_NDIS_SET_CMPLT 0x80000005U
#define REMOTE_NDIS_RESET_CMPLT 0x80000006U
#define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008U
/* Device Flags */ /* Device Flags */
#define RNDIS_DF_CONNECTIONLESS 0x00000001U #define RNDIS_DF_CONNECTIONLESS 0x00000001U
#define RNDIS_DF_CONNECTION_ORIENTED 0x00000002U #define RNDIS_DF_CONNECTION_ORIENTED 0x00000002U
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment