Commit ead00ddc authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Revert "Staging: dgrp: Refactor the function dgrp_receive() in drrp_net_ops.c"

This reverts commit b73db547.
Reported-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Reported-by: default avatarChen Gang <gang.chen.5i5j@gmail.com>
Cc: Rashika Kheria <rashika.kheria@gmail.com>
Cc: James Hogan <james.hogan@imgtec.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0010b79d
......@@ -2232,20 +2232,114 @@ static ssize_t dgrp_net_read(struct file *file, char __user *buf, size_t count,
return rtn;
}
/*
* Common Packet Handling code
/**
* dgrp_receive() -- decode data packets received from the remote PortServer.
* @nd: pointer to a node structure
*/
static void handle_data_in_packet(struct nd_struct *nd, struct ch_struct *ch,
long dlen, long plen, int n1, u8 *dbuf)
static void dgrp_receive(struct nd_struct *nd)
{
char *error;
long n;
long remain;
struct ch_struct *ch;
u8 *buf;
u8 *b;
u8 *dbuf;
char *error;
long port;
long dlen;
long plen;
long remain;
long n;
long mlast;
long elast;
long mstat;
long estat;
char ID[3];
nd->nd_tx_time = jiffies;
ID_TO_CHAR(nd->nd_ID, ID);
b = buf = nd->nd_iobuf;
remain = nd->nd_remain;
/*
* Loop to process Realport protocol packets.
*/
while (remain > 0) {
int n0 = b[0] >> 4;
int n1 = b[0] & 0x0f;
if (n0 <= 12) {
port = (nd->nd_rx_module << 4) + n1;
if (port >= nd->nd_chan_count) {
error = "Improper Port Number";
goto prot_error;
}
ch = nd->nd_chan + port;
} else {
port = -1;
ch = NULL;
}
/*
* Process by major packet type.
*/
switch (n0) {
/*
* Process 1-byte header data packet.
*/
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
dlen = n0 + 1;
plen = dlen + 1;
dbuf = b + 1;
goto data;
/*
* Process 2-byte header data packet.
*/
case 8:
if (remain < 3)
goto done;
dlen = b[1];
plen = dlen + 2;
dbuf = b + 2;
goto data;
/*
* Process 3-byte header data packet.
*/
case 9:
if (remain < 4)
goto done;
dlen = get_unaligned_be16(b + 1);
plen = dlen + 3;
dbuf = b + 3;
/*
* Common packet handling code.
*/
data:
nd->nd_tx_work = 1;
/*
......@@ -2255,9 +2349,7 @@ static void handle_data_in_packet(struct nd_struct *nd, struct ch_struct *ch,
if (ch->ch_state < CS_READY) {
error = "Data received before RWIN established";
nd->nd_remain = 0;
nd->nd_state = NS_SEND_ERROR;
nd->nd_error = error;
goto prot_error;
}
/*
......@@ -2269,9 +2361,7 @@ static void handle_data_in_packet(struct nd_struct *nd, struct ch_struct *ch,
if (dlen > n) {
error = "Receive data overrun";
nd->nd_remain = 0;
nd->nd_state = NS_SEND_ERROR;
nd->nd_error = error;
goto prot_error;
}
/*
......@@ -2378,6 +2468,7 @@ static void handle_data_in_packet(struct nd_struct *nd, struct ch_struct *ch,
if ((ch->ch_flag & CH_INPUT) != 0) {
ch->ch_flag &= ~CH_INPUT;
wake_up_interruptible(&ch->ch_flag_wait);
}
}
......@@ -2395,119 +2486,8 @@ static void handle_data_in_packet(struct nd_struct *nd, struct ch_struct *ch,
put_unaligned_be16(dlen, b + 1);
remain = 3;
if (remain > 0 && b != buf)
memcpy(buf, b, remain);
nd->nd_remain = remain;
return;
}
}
/**
* dgrp_receive() -- decode data packets received from the remote PortServer.
* @nd: pointer to a node structure
*/
static void dgrp_receive(struct nd_struct *nd)
{
struct ch_struct *ch;
u8 *buf;
u8 *b;
u8 *dbuf;
char *error;
long port;
long dlen;
long plen;
long remain;
long n;
long mlast;
long elast;
long mstat;
long estat;
char ID[3];
nd->nd_tx_time = jiffies;
ID_TO_CHAR(nd->nd_ID, ID);
b = buf = nd->nd_iobuf;
remain = nd->nd_remain;
/*
* Loop to process Realport protocol packets.
*/
while (remain > 0) {
int n0 = b[0] >> 4;
int n1 = b[0] & 0x0f;
if (n0 <= 12) {
port = (nd->nd_rx_module << 4) + n1;
if (port >= nd->nd_chan_count) {
error = "Improper Port Number";
goto prot_error;
}
ch = nd->nd_chan + port;
} else {
port = -1;
ch = NULL;
}
/*
* Process by major packet type.
*/
switch (n0) {
/*
* Process 1-byte header data packet.
*/
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
dlen = n0 + 1;
plen = dlen + 1;
dbuf = b + 1;
handle_data_in_packet(nd, ch, dlen, plen, n1, dbuf);
break;
/*
* Process 2-byte header data packet.
*/
case 8:
if (remain < 3)
goto done;
dlen = b[1];
plen = dlen + 2;
dbuf = b + 2;
handle_data_in_packet(nd, ch, dlen, plen, n1, dbuf);
break;
/*
* Process 3-byte header data packet.
*/
case 9:
if (remain < 4)
goto done;
dlen = get_unaligned_be16(b + 1);
plen = dlen + 3;
dbuf = b + 3;
}
break;
/*
......
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