From a73588fe481ffe39e3021decdc73a5b358f0776c Mon Sep 17 00:00:00 2001 From: Joe Hershberger Date: Fri, 9 Sep 2016 12:56:26 -0500 Subject: Revert "net: nfs: Use the tx buffer to construct rpc msgs" This reverts commit 998372b4798fd7ebb666f571950df925b8d80f69. This caused a data abort on some platform. Signed-off-by: Joe Hershberger Reported-by: Guillaume GARDET diff --git a/net/nfs.c b/net/nfs.c index 814751b..83ed0a7 100644 --- a/net/nfs.c +++ b/net/nfs.c @@ -170,41 +170,41 @@ static uint32_t *rpc_add_credentials(uint32_t *p) /************************************************************************** RPC_LOOKUP - Lookup RPC Port numbers **************************************************************************/ -static struct rpc_t *rpc_req_prep(void) -{ - return (struct rpc_t *)(net_tx_packet + net_eth_hdr_size() + - IP_UDP_HDR_SIZE); -} - -static void rpc_req(int rpc_prog, int rpc_proc, struct rpc_t *rpc_pkt, - int datalen) +static void rpc_req(int rpc_prog, int rpc_proc, uint32_t *data, int datalen) { + struct rpc_t rpc_pkt; unsigned long id; + uint32_t *p; int pktlen; int sport; id = ++rpc_id; - rpc_pkt->u.call.id = htonl(id); - rpc_pkt->u.call.type = htonl(MSG_CALL); - rpc_pkt->u.call.rpcvers = htonl(2); /* use RPC version 2 */ - rpc_pkt->u.call.prog = htonl(rpc_prog); + rpc_pkt.u.call.id = htonl(id); + rpc_pkt.u.call.type = htonl(MSG_CALL); + rpc_pkt.u.call.rpcvers = htonl(2); /* use RPC version 2 */ + rpc_pkt.u.call.prog = htonl(rpc_prog); switch (rpc_prog) { case PROG_NFS: if (supported_nfs_versions & NFSV2_FLAG) - rpc_pkt->u.call.vers = htonl(2); /* NFS v2 */ + rpc_pkt.u.call.vers = htonl(2); /* NFS v2 */ else /* NFSV3_FLAG */ - rpc_pkt->u.call.vers = htonl(3); /* NFS v3 */ + rpc_pkt.u.call.vers = htonl(3); /* NFS v3 */ break; case PROG_PORTMAP: case PROG_MOUNT: default: - /* portmapper is version 2 */ - rpc_pkt->u.call.vers = htonl(2); + rpc_pkt.u.call.vers = htonl(2); /* portmapper is version 2 */ } - rpc_pkt->u.call.proc = htonl(rpc_proc); + rpc_pkt.u.call.proc = htonl(rpc_proc); + p = (uint32_t *)&(rpc_pkt.u.call.data); + + if (datalen) + memcpy((char *)p, (char *)data, datalen*sizeof(uint32_t)); + + pktlen = (char *)p + datalen * sizeof(uint32_t) - (char *)&rpc_pkt; - pktlen = ((char *)&rpc_pkt->u.call.data - (char *)&rpc_pkt) + - datalen * sizeof(uint32_t); + memcpy((char *)net_tx_packet + net_eth_hdr_size() + IP_UDP_HDR_SIZE, + &rpc_pkt.u.data[0], pktlen); if (rpc_prog == PROG_PORTMAP) sport = SUNRPC_PORT; @@ -222,17 +222,15 @@ RPC_LOOKUP - Lookup RPC Port numbers **************************************************************************/ static void rpc_lookup_req(int prog, int ver) { - uint32_t *data; - struct rpc_t *rpc_pkt = rpc_req_prep(); + uint32_t data[16]; - data = rpc_pkt->u.call.data; data[0] = 0; data[1] = 0; /* auth credential */ data[2] = 0; data[3] = 0; /* auth verifier */ data[4] = htonl(prog); data[5] = htonl(ver); data[6] = htonl(17); /* IP_UDP */ data[7] = 0; - rpc_req(PROG_PORTMAP, PORTMAP_GETPORT, rpc_pkt, 8); + rpc_req(PROG_PORTMAP, PORTMAP_GETPORT, data, 8); } /************************************************************************** @@ -240,14 +238,14 @@ NFS_MOUNT - Mount an NFS Filesystem **************************************************************************/ static void nfs_mount_req(char *path) { + uint32_t data[1024]; uint32_t *p; int len; int pathlen; - struct rpc_t *rpc_pkt = rpc_req_prep(); pathlen = strlen(path); - p = rpc_pkt->u.call.data; + p = &(data[0]); p = rpc_add_credentials(p); *p++ = htonl(pathlen); @@ -256,9 +254,9 @@ static void nfs_mount_req(char *path) memcpy(p, path, pathlen); p += (pathlen + 3) / 4; - len = (uint32_t *)p - (uint32_t *)&(rpc_pkt->u.call.data); + len = (uint32_t *)p - (uint32_t *)&(data[0]); - rpc_req(PROG_MOUNT, MOUNT_ADDENTRY, rpc_pkt, len); + rpc_req(PROG_MOUNT, MOUNT_ADDENTRY, data, len); } /************************************************************************** @@ -266,20 +264,20 @@ NFS_UMOUNTALL - Unmount all our NFS Filesystems on the Server **************************************************************************/ static void nfs_umountall_req(void) { + uint32_t data[1024]; uint32_t *p; int len; - struct rpc_t *rpc_pkt = rpc_req_prep(); if ((nfs_server_mount_port == -1) || (!fs_mounted)) /* Nothing mounted, nothing to umount */ return; - p = rpc_pkt->u.call.data; + p = &(data[0]); p = rpc_add_credentials(p); - len = (uint32_t *)p - (uint32_t *)&(rpc_pkt->u.call.data); + len = (uint32_t *)p - (uint32_t *)&(data[0]); - rpc_req(PROG_MOUNT, MOUNT_UMOUNTALL, rpc_pkt, len); + rpc_req(PROG_MOUNT, MOUNT_UMOUNTALL, data, len); } /*************************************************************************** @@ -291,11 +289,11 @@ static void nfs_umountall_req(void) **************************************************************************/ static void nfs_readlink_req(void) { + uint32_t data[1024]; uint32_t *p; int len; - struct rpc_t *rpc_pkt = rpc_req_prep(); - p = rpc_pkt->u.call.data; + p = &(data[0]); p = rpc_add_credentials(p); if (supported_nfs_versions & NFSV2_FLAG) { @@ -307,9 +305,9 @@ static void nfs_readlink_req(void) p += (filefh3_length / 4); } - len = (uint32_t *)p - (uint32_t *)&(rpc_pkt->u.call.data); + len = (uint32_t *)p - (uint32_t *)&(data[0]); - rpc_req(PROG_NFS, NFS_READLINK, rpc_pkt, len); + rpc_req(PROG_NFS, NFS_READLINK, data, len); } /************************************************************************** @@ -317,14 +315,14 @@ NFS_LOOKUP - Lookup Pathname **************************************************************************/ static void nfs_lookup_req(char *fname) { + uint32_t data[1024]; uint32_t *p; int len; int fnamelen; - struct rpc_t *rpc_pkt = rpc_req_prep(); fnamelen = strlen(fname); - p = rpc_pkt->u.call.data; + p = &(data[0]); p = rpc_add_credentials(p); if (supported_nfs_versions & NFSV2_FLAG) { @@ -336,9 +334,9 @@ static void nfs_lookup_req(char *fname) memcpy(p, fname, fnamelen); p += (fnamelen + 3) / 4; - len = (uint32_t *)p - (uint32_t *)&(rpc_pkt->u.call.data); + len = (uint32_t *)p - (uint32_t *)&(data[0]); - rpc_req(PROG_NFS, NFS_LOOKUP, rpc_pkt, len); + rpc_req(PROG_NFS, NFS_LOOKUP, data, len); } else { /* NFSV3_FLAG */ *p++ = htonl(NFS_FHSIZE); /* Dir handle length */ memcpy(p, dirfh, NFS_FHSIZE); @@ -349,9 +347,9 @@ static void nfs_lookup_req(char *fname) memcpy(p, fname, fnamelen); p += (fnamelen + 3) / 4; - len = (uint32_t *)p - (uint32_t *)&(rpc_pkt->u.call.data); + len = (uint32_t *)p - (uint32_t *)&(data[0]); - rpc_req(PROG_NFS, NFS3PROC_LOOKUP, rpc_pkt, len); + rpc_req(PROG_NFS, NFS3PROC_LOOKUP, data, len); } } @@ -360,11 +358,11 @@ NFS_READ - Read File on NFS Server **************************************************************************/ static void nfs_read_req(int offset, int readlen) { + uint32_t data[1024]; uint32_t *p; int len; - struct rpc_t *rpc_pkt = rpc_req_prep(); - p = rpc_pkt->u.call.data; + p = &(data[0]); p = rpc_add_credentials(p); if (supported_nfs_versions & NFSV2_FLAG) { @@ -383,9 +381,9 @@ static void nfs_read_req(int offset, int readlen) *p++ = 0; } - len = (uint32_t *)p - (uint32_t *)&(rpc_pkt->u.call.data); + len = (uint32_t *)p - (uint32_t *)&(data[0]); - rpc_req(PROG_NFS, NFS_READ, rpc_pkt, len); + rpc_req(PROG_NFS, NFS_READ, data, len); } /************************************************************************** -- cgit v0.10.2 From 11e8ec96dcff19ac0e0232a1ae10999398d64e3b Mon Sep 17 00:00:00 2001 From: Joe Hershberger Date: Fri, 9 Sep 2016 13:01:24 -0500 Subject: Revert "net: nfs: Correct the reply data buffer size" This reverts commit 6279b49e6c2fdaf8665355d1777bc90cd41fcf90. This caused a bad data crc. Signed-off-by: Joe Hershberger Reported-by: Guillaume GARDET diff --git a/net/nfs.h b/net/nfs.h index aa4e450..45da246 100644 --- a/net/nfs.h +++ b/net/nfs.h @@ -76,7 +76,7 @@ struct rpc_t { uint32_t verifier; uint32_t v2; uint32_t astatus; - uint32_t data[NFS_READ_SIZE / sizeof(uint32_t)]; + uint32_t data[NFS_READ_SIZE]; } reply; } u; }; -- cgit v0.10.2 From 41d1258aceb45b45f9e68f67a9c40f0afbc09dc9 Mon Sep 17 00:00:00 2001 From: Joshua Scott Date: Tue, 6 Sep 2016 16:03:11 +1200 Subject: net: asix: Fix AX88772B when used with DriverModel A previous patch (net: asix: fix operation without eeprom) added a two-byte shift to the packet buffer when receiving a packet on the AX88772B. This shift was not included when the driver was updated to work with DriverModel. Testing on a Marvell DB-88F6820-ACM showed that the adapter was not functioning correctly (EHCI timeouts). This patch brings the two-byte shift to the DriverModel implementation of ops->recv (asix_eth_recv). Testing on the same board, we were able to TFTP a file over and confirm that the crc32 was correct. Signed-off-by: Joshua Scott Acked-by: Joe Hershberger diff --git a/drivers/usb/eth/asix.c b/drivers/usb/eth/asix.c index ad083cf..a610ae4 100644 --- a/drivers/usb/eth/asix.c +++ b/drivers/usb/eth/asix.c @@ -819,6 +819,11 @@ int asix_eth_recv(struct udevice *dev, int flags, uchar **packetp) } *packetp = ptr + sizeof(packet_len); + + if ((ueth->pusb_dev->descriptor.idVendor == ASIX_USB_VENDOR_ID) && + (ueth->pusb_dev->descriptor.idProduct == AX88772B_USB_PRODUCT_ID)) + *packetp += 2; + return packet_len; err: -- cgit v0.10.2