Commit e660a828 authored by Eric Van Hensbergen's avatar Eric Van Hensbergen

9p: clean up packet dump code

Switch to generic kernel hexdump library and cleanup macros to
be more consistent with the way we do normal debug prints.
Signed-off-by: default avatarEric Van Hensbergen <ericvh@gmail.com>
parent 2053d67c
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
* @P9_DEBUG_FID: fid allocation/deallocation tracking * @P9_DEBUG_FID: fid allocation/deallocation tracking
* @P9_DEBUG_PKT: packet marshalling/unmarshalling * @P9_DEBUG_PKT: packet marshalling/unmarshalling
* @P9_DEBUG_FSC: FS-cache tracing * @P9_DEBUG_FSC: FS-cache tracing
* @P9_DEBUG_VPKT: Verbose packet debugging (full packet dump)
* *
* These flags are passed at mount time to turn on various levels of * These flags are passed at mount time to turn on various levels of
* verbosity and tracing which will be output to the system logs. * verbosity and tracing which will be output to the system logs.
...@@ -57,6 +58,7 @@ enum p9_debug_flags { ...@@ -57,6 +58,7 @@ enum p9_debug_flags {
P9_DEBUG_FID = (1<<9), P9_DEBUG_FID = (1<<9),
P9_DEBUG_PKT = (1<<10), P9_DEBUG_PKT = (1<<10),
P9_DEBUG_FSC = (1<<11), P9_DEBUG_FSC = (1<<11),
P9_DEBUG_VPKT = (1<<12),
}; };
#ifdef CONFIG_NET_9P_DEBUG #ifdef CONFIG_NET_9P_DEBUG
...@@ -74,10 +76,14 @@ do { \ ...@@ -74,10 +76,14 @@ do { \
} \ } \
} while (0) } while (0)
#define P9_DUMP_PKT(way, pdu) p9pdu_dump(way, pdu)
#else #else
#define P9_DPRINTK(level, format, arg...) do { } while (0) #define P9_DPRINTK(level, format, arg...) do { } while (0)
#define P9_DUMP_PKT(way, pdu) do { } while (0)
#endif #endif
#define P9_EPRINTK(level, format, arg...) \ #define P9_EPRINTK(level, format, arg...) \
do { \ do { \
printk(level "9p: %s (%d): " \ printk(level "9p: %s (%d): " \
......
...@@ -750,7 +750,7 @@ static int p9_client_version(struct p9_client *c) ...@@ -750,7 +750,7 @@ static int p9_client_version(struct p9_client *c)
err = p9pdu_readf(req->rc, c->proto_version, "ds", &msize, &version); err = p9pdu_readf(req->rc, c->proto_version, "ds", &msize, &version);
if (err) { if (err) {
P9_DPRINTK(P9_DEBUG_9P, "version error %d\n", err); P9_DPRINTK(P9_DEBUG_9P, "version error %d\n", err);
p9pdu_dump(1, req->rc); P9_DUMP_PKT(1, req->rc);
goto error; goto error;
} }
...@@ -912,7 +912,7 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid, ...@@ -912,7 +912,7 @@ struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid,
err = p9pdu_readf(req->rc, clnt->proto_version, "Q", &qid); err = p9pdu_readf(req->rc, clnt->proto_version, "Q", &qid);
if (err) { if (err) {
p9pdu_dump(1, req->rc); P9_DUMP_PKT(1, req->rc);
p9_free_req(clnt, req); p9_free_req(clnt, req);
goto error; goto error;
} }
...@@ -972,7 +972,7 @@ struct p9_fid *p9_client_walk(struct p9_fid *oldfid, uint16_t nwname, ...@@ -972,7 +972,7 @@ struct p9_fid *p9_client_walk(struct p9_fid *oldfid, uint16_t nwname,
err = p9pdu_readf(req->rc, clnt->proto_version, "R", &nwqids, &wqids); err = p9pdu_readf(req->rc, clnt->proto_version, "R", &nwqids, &wqids);
if (err) { if (err) {
p9pdu_dump(1, req->rc); P9_DUMP_PKT(1, req->rc);
p9_free_req(clnt, req); p9_free_req(clnt, req);
goto clunk_fid; goto clunk_fid;
} }
...@@ -1039,7 +1039,7 @@ int p9_client_open(struct p9_fid *fid, int mode) ...@@ -1039,7 +1039,7 @@ int p9_client_open(struct p9_fid *fid, int mode)
err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", &qid, &iounit); err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", &qid, &iounit);
if (err) { if (err) {
p9pdu_dump(1, req->rc); P9_DUMP_PKT(1, req->rc);
goto free_and_error; goto free_and_error;
} }
...@@ -1082,7 +1082,7 @@ int p9_client_create_dotl(struct p9_fid *ofid, char *name, u32 flags, u32 mode, ...@@ -1082,7 +1082,7 @@ int p9_client_create_dotl(struct p9_fid *ofid, char *name, u32 flags, u32 mode,
err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", qid, &iounit); err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", qid, &iounit);
if (err) { if (err) {
p9pdu_dump(1, req->rc); P9_DUMP_PKT(1, req->rc);
goto free_and_error; goto free_and_error;
} }
...@@ -1127,7 +1127,7 @@ int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode, ...@@ -1127,7 +1127,7 @@ int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode,
err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", &qid, &iounit); err = p9pdu_readf(req->rc, clnt->proto_version, "Qd", &qid, &iounit);
if (err) { if (err) {
p9pdu_dump(1, req->rc); P9_DUMP_PKT(1, req->rc);
goto free_and_error; goto free_and_error;
} }
...@@ -1166,7 +1166,7 @@ int p9_client_symlink(struct p9_fid *dfid, char *name, char *symtgt, gid_t gid, ...@@ -1166,7 +1166,7 @@ int p9_client_symlink(struct p9_fid *dfid, char *name, char *symtgt, gid_t gid,
err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid); err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid);
if (err) { if (err) {
p9pdu_dump(1, req->rc); P9_DUMP_PKT(1, req->rc);
goto free_and_error; goto free_and_error;
} }
...@@ -1319,11 +1319,12 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset, ...@@ -1319,11 +1319,12 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset,
err = p9pdu_readf(req->rc, clnt->proto_version, "D", &count, &dataptr); err = p9pdu_readf(req->rc, clnt->proto_version, "D", &count, &dataptr);
if (err) { if (err) {
p9pdu_dump(1, req->rc); P9_DUMP_PKT(1, req->rc);
goto free_and_error; goto free_and_error;
} }
P9_DPRINTK(P9_DEBUG_9P, "<<< RREAD count %d\n", count); P9_DPRINTK(P9_DEBUG_9P, "<<< RREAD count %d\n", count);
P9_DUMP_PKT(1, req->rc);
if (!req->tc->pbuf_size) { if (!req->tc->pbuf_size) {
if (data) { if (data) {
...@@ -1387,7 +1388,7 @@ p9_client_write(struct p9_fid *fid, char *data, const char __user *udata, ...@@ -1387,7 +1388,7 @@ p9_client_write(struct p9_fid *fid, char *data, const char __user *udata,
err = p9pdu_readf(req->rc, clnt->proto_version, "d", &count); err = p9pdu_readf(req->rc, clnt->proto_version, "d", &count);
if (err) { if (err) {
p9pdu_dump(1, req->rc); P9_DUMP_PKT(1, req->rc);
goto free_and_error; goto free_and_error;
} }
...@@ -1427,7 +1428,7 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid) ...@@ -1427,7 +1428,7 @@ struct p9_wstat *p9_client_stat(struct p9_fid *fid)
err = p9pdu_readf(req->rc, clnt->proto_version, "wS", &ignored, ret); err = p9pdu_readf(req->rc, clnt->proto_version, "wS", &ignored, ret);
if (err) { if (err) {
p9pdu_dump(1, req->rc); P9_DUMP_PKT(1, req->rc);
p9_free_req(clnt, req); p9_free_req(clnt, req);
goto error; goto error;
} }
...@@ -1478,7 +1479,7 @@ struct p9_stat_dotl *p9_client_getattr_dotl(struct p9_fid *fid, ...@@ -1478,7 +1479,7 @@ struct p9_stat_dotl *p9_client_getattr_dotl(struct p9_fid *fid,
err = p9pdu_readf(req->rc, clnt->proto_version, "A", ret); err = p9pdu_readf(req->rc, clnt->proto_version, "A", ret);
if (err) { if (err) {
p9pdu_dump(1, req->rc); P9_DUMP_PKT(1, req->rc);
p9_free_req(clnt, req); p9_free_req(clnt, req);
goto error; goto error;
} }
...@@ -1626,7 +1627,7 @@ int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb) ...@@ -1626,7 +1627,7 @@ int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb)
&sb->bsize, &sb->blocks, &sb->bfree, &sb->bavail, &sb->bsize, &sb->blocks, &sb->bfree, &sb->bavail,
&sb->files, &sb->ffree, &sb->fsid, &sb->namelen); &sb->files, &sb->ffree, &sb->fsid, &sb->namelen);
if (err) { if (err) {
p9pdu_dump(1, req->rc); P9_DUMP_PKT(1, req->rc);
p9_free_req(clnt, req); p9_free_req(clnt, req);
goto error; goto error;
} }
...@@ -1702,7 +1703,7 @@ struct p9_fid *p9_client_xattrwalk(struct p9_fid *file_fid, ...@@ -1702,7 +1703,7 @@ struct p9_fid *p9_client_xattrwalk(struct p9_fid *file_fid,
} }
err = p9pdu_readf(req->rc, clnt->proto_version, "q", attr_size); err = p9pdu_readf(req->rc, clnt->proto_version, "q", attr_size);
if (err) { if (err) {
p9pdu_dump(1, req->rc); P9_DUMP_PKT(1, req->rc);
p9_free_req(clnt, req); p9_free_req(clnt, req);
goto clunk_fid; goto clunk_fid;
} }
...@@ -1781,7 +1782,7 @@ int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset) ...@@ -1781,7 +1782,7 @@ int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset)
err = p9pdu_readf(req->rc, clnt->proto_version, "D", &count, &dataptr); err = p9pdu_readf(req->rc, clnt->proto_version, "D", &count, &dataptr);
if (err) { if (err) {
p9pdu_dump(1, req->rc); P9_DUMP_PKT(1, req->rc);
goto free_and_error; goto free_and_error;
} }
...@@ -1818,7 +1819,7 @@ int p9_client_mknod_dotl(struct p9_fid *fid, char *name, int mode, ...@@ -1818,7 +1819,7 @@ int p9_client_mknod_dotl(struct p9_fid *fid, char *name, int mode,
err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid); err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid);
if (err) { if (err) {
p9pdu_dump(1, req->rc); P9_DUMP_PKT(1, req->rc);
goto error; goto error;
} }
P9_DPRINTK(P9_DEBUG_9P, "<<< RMKNOD qid %x.%llx.%x\n", qid->type, P9_DPRINTK(P9_DEBUG_9P, "<<< RMKNOD qid %x.%llx.%x\n", qid->type,
...@@ -1849,7 +1850,7 @@ int p9_client_mkdir_dotl(struct p9_fid *fid, char *name, int mode, ...@@ -1849,7 +1850,7 @@ int p9_client_mkdir_dotl(struct p9_fid *fid, char *name, int mode,
err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid); err = p9pdu_readf(req->rc, clnt->proto_version, "Q", qid);
if (err) { if (err) {
p9pdu_dump(1, req->rc); P9_DUMP_PKT(1, req->rc);
goto error; goto error;
} }
P9_DPRINTK(P9_DEBUG_9P, "<<< RMKDIR qid %x.%llx.%x\n", qid->type, P9_DPRINTK(P9_DEBUG_9P, "<<< RMKDIR qid %x.%llx.%x\n", qid->type,
...@@ -1884,7 +1885,7 @@ int p9_client_lock_dotl(struct p9_fid *fid, struct p9_flock *flock, u8 *status) ...@@ -1884,7 +1885,7 @@ int p9_client_lock_dotl(struct p9_fid *fid, struct p9_flock *flock, u8 *status)
err = p9pdu_readf(req->rc, clnt->proto_version, "b", status); err = p9pdu_readf(req->rc, clnt->proto_version, "b", status);
if (err) { if (err) {
p9pdu_dump(1, req->rc); P9_DUMP_PKT(1, req->rc);
goto error; goto error;
} }
P9_DPRINTK(P9_DEBUG_9P, "<<< RLOCK status %i\n", *status); P9_DPRINTK(P9_DEBUG_9P, "<<< RLOCK status %i\n", *status);
...@@ -1917,7 +1918,7 @@ int p9_client_getlock_dotl(struct p9_fid *fid, struct p9_getlock *glock) ...@@ -1917,7 +1918,7 @@ int p9_client_getlock_dotl(struct p9_fid *fid, struct p9_getlock *glock)
&glock->start, &glock->length, &glock->proc_id, &glock->start, &glock->length, &glock->proc_id,
&glock->client_id); &glock->client_id);
if (err) { if (err) {
p9pdu_dump(1, req->rc); P9_DUMP_PKT(1, req->rc);
goto error; goto error;
} }
P9_DPRINTK(P9_DEBUG_9P, "<<< RGETLOCK type %i start %lld length %lld " P9_DPRINTK(P9_DEBUG_9P, "<<< RGETLOCK type %i start %lld length %lld "
...@@ -1945,7 +1946,7 @@ int p9_client_readlink(struct p9_fid *fid, char **target) ...@@ -1945,7 +1946,7 @@ int p9_client_readlink(struct p9_fid *fid, char **target)
err = p9pdu_readf(req->rc, clnt->proto_version, "s", target); err = p9pdu_readf(req->rc, clnt->proto_version, "s", target);
if (err) { if (err) {
p9pdu_dump(1, req->rc); P9_DUMP_PKT(1, req->rc);
goto error; goto error;
} }
P9_DPRINTK(P9_DEBUG_9P, "<<< RREADLINK target %s\n", *target); P9_DPRINTK(P9_DEBUG_9P, "<<< RREADLINK target %s\n", *target);
......
...@@ -44,30 +44,24 @@ p9pdu_writef(struct p9_fcall *pdu, int proto_version, const char *fmt, ...); ...@@ -44,30 +44,24 @@ p9pdu_writef(struct p9_fcall *pdu, int proto_version, const char *fmt, ...);
void void
p9pdu_dump(int way, struct p9_fcall *pdu) p9pdu_dump(int way, struct p9_fcall *pdu)
{ {
int i, n; int len = pdu->size;
u8 *data = pdu->sdata;
int datalen = pdu->size; if ((p9_debug_level & P9_DEBUG_VPKT) != P9_DEBUG_VPKT) {
char buf[255]; if ((p9_debug_level & P9_DEBUG_PKT) == P9_DEBUG_PKT) {
int buflen = 255; if (len > 32)
len = 32;
i = n = 0; } else {
if (datalen > (buflen-16)) /* shouldn't happen */
datalen = buflen-16; return;
while (i < datalen) { }
n += scnprintf(buf + n, buflen - n, "%02x ", data[i]); }
if (i%4 == 3)
n += scnprintf(buf + n, buflen - n, " ");
if (i%32 == 31)
n += scnprintf(buf + n, buflen - n, "\n");
i++;
}
n += scnprintf(buf + n, buflen - n, "\n");
if (way) if (way)
P9_DPRINTK(P9_DEBUG_PKT, "[[[(%d) %s\n", datalen, buf); print_hex_dump_bytes("[9P] ", DUMP_PREFIX_OFFSET, pdu->sdata,
len);
else else
P9_DPRINTK(P9_DEBUG_PKT, "]]](%d) %s\n", datalen, buf); print_hex_dump_bytes("]9P[ ", DUMP_PREFIX_OFFSET, pdu->sdata,
len);
} }
#else #else
void void
...@@ -610,7 +604,7 @@ int p9stat_read(char *buf, int len, struct p9_wstat *st, int proto_version) ...@@ -610,7 +604,7 @@ int p9stat_read(char *buf, int len, struct p9_wstat *st, int proto_version)
ret = p9pdu_readf(&fake_pdu, proto_version, "S", st); ret = p9pdu_readf(&fake_pdu, proto_version, "S", st);
if (ret) { if (ret) {
P9_DPRINTK(P9_DEBUG_9P, "<<< p9stat_read failed: %d\n", ret); P9_DPRINTK(P9_DEBUG_9P, "<<< p9stat_read failed: %d\n", ret);
p9pdu_dump(1, &fake_pdu); P9_DUMP_PKT(0, &fake_pdu);
} }
return ret; return ret;
...@@ -632,11 +626,7 @@ int p9pdu_finalize(struct p9_fcall *pdu) ...@@ -632,11 +626,7 @@ int p9pdu_finalize(struct p9_fcall *pdu)
err = p9pdu_writef(pdu, 0, "d", size); err = p9pdu_writef(pdu, 0, "d", size);
pdu->size = size; pdu->size = size;
#ifdef CONFIG_NET_9P_DEBUG P9_DUMP_PKT(0, pdu);
if ((p9_debug_level & P9_DEBUG_PKT) == P9_DEBUG_PKT)
p9pdu_dump(0, pdu);
#endif
P9_DPRINTK(P9_DEBUG_9P, ">>> size=%d type: %d tag: %d\n", pdu->size, P9_DPRINTK(P9_DEBUG_9P, ">>> size=%d type: %d tag: %d\n", pdu->size,
pdu->id, pdu->tag); pdu->id, pdu->tag);
...@@ -669,7 +659,7 @@ int p9dirent_read(char *buf, int len, struct p9_dirent *dirent, ...@@ -669,7 +659,7 @@ int p9dirent_read(char *buf, int len, struct p9_dirent *dirent,
&dirent->d_off, &dirent->d_type, &nameptr); &dirent->d_off, &dirent->d_type, &nameptr);
if (ret) { if (ret) {
P9_DPRINTK(P9_DEBUG_9P, "<<< p9dirent_read failed: %d\n", ret); P9_DPRINTK(P9_DEBUG_9P, "<<< p9dirent_read failed: %d\n", ret);
p9pdu_dump(1, &fake_pdu); P9_DUMP_PKT(1, &fake_pdu);
goto out; goto out;
} }
......
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