Commit aa3f2cb6 authored by Peter Tiedemann's avatar Peter Tiedemann Committed by Jeff Garzik

s390/net/ctcm: message cleanup

Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: default avatarPeter Tiedemann <ptiedem@de.ibm.com>
Signed-off-by: default avatarUrsula Braun <ursula.braun@de.ibm.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent b805da74
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
*/ */
#include <linux/stddef.h> #include <linux/stddef.h>
#include <linux/string.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -22,15 +23,13 @@ ...@@ -22,15 +23,13 @@
* Debug Facility Stuff * Debug Facility Stuff
*/ */
DEFINE_PER_CPU(char[256], ctcm_dbf_txt_buf);
struct ctcm_dbf_info ctcm_dbf[CTCM_DBF_INFOS] = { struct ctcm_dbf_info ctcm_dbf[CTCM_DBF_INFOS] = {
[CTCM_DBF_SETUP] = {"ctc_setup", 8, 1, 64, 5, NULL}, [CTCM_DBF_SETUP] = {"ctc_setup", 8, 1, 64, CTC_DBF_INFO, NULL},
[CTCM_DBF_ERROR] = {"ctc_error", 8, 1, 64, 3, NULL}, [CTCM_DBF_ERROR] = {"ctc_error", 8, 1, 64, CTC_DBF_ERROR, NULL},
[CTCM_DBF_TRACE] = {"ctc_trace", 8, 1, 64, 3, NULL}, [CTCM_DBF_TRACE] = {"ctc_trace", 8, 1, 64, CTC_DBF_ERROR, NULL},
[CTCM_DBF_MPC_SETUP] = {"mpc_setup", 8, 1, 64, 5, NULL}, [CTCM_DBF_MPC_SETUP] = {"mpc_setup", 8, 1, 80, CTC_DBF_INFO, NULL},
[CTCM_DBF_MPC_ERROR] = {"mpc_error", 8, 1, 64, 3, NULL}, [CTCM_DBF_MPC_ERROR] = {"mpc_error", 8, 1, 80, CTC_DBF_ERROR, NULL},
[CTCM_DBF_MPC_TRACE] = {"mpc_trace", 8, 1, 64, 3, NULL}, [CTCM_DBF_MPC_TRACE] = {"mpc_trace", 8, 1, 80, CTC_DBF_ERROR, NULL},
}; };
void ctcm_unregister_dbf_views(void) void ctcm_unregister_dbf_views(void)
...@@ -65,3 +64,17 @@ int ctcm_register_dbf_views(void) ...@@ -65,3 +64,17 @@ int ctcm_register_dbf_views(void)
return 0; return 0;
} }
void ctcm_dbf_longtext(enum ctcm_dbf_names dbf_nix, int level, char *fmt, ...)
{
char dbf_txt_buf[64];
va_list args;
if (level > (ctcm_dbf[dbf_nix].id)->level)
return;
va_start(args, fmt);
vsnprintf(dbf_txt_buf, sizeof(dbf_txt_buf), fmt, args);
va_end(args);
debug_text_event(ctcm_dbf[dbf_nix].id, level, dbf_txt_buf);
}
...@@ -20,16 +20,17 @@ ...@@ -20,16 +20,17 @@
#else #else
#define do_debug 0 #define do_debug 0
#endif #endif
#ifdef DEBUGDATA
#define do_debug_data 1
#else
#define do_debug_data 0
#endif
#ifdef DEBUGCCW #ifdef DEBUGCCW
#define do_debug_ccw 1 #define do_debug_ccw 1
#define DEBUGDATA 1
#else #else
#define do_debug_ccw 0 #define do_debug_ccw 0
#endif #endif
#ifdef DEBUGDATA
#define do_debug_data 1
#else
#define do_debug_data 0
#endif
/* define dbf debug levels similar to kernel msg levels */ /* define dbf debug levels similar to kernel msg levels */
#define CTC_DBF_ALWAYS 0 /* always print this */ #define CTC_DBF_ALWAYS 0 /* always print this */
...@@ -42,8 +43,6 @@ ...@@ -42,8 +43,6 @@
#define CTC_DBF_INFO 5 /* informational */ #define CTC_DBF_INFO 5 /* informational */
#define CTC_DBF_DEBUG 6 /* debug-level messages */ #define CTC_DBF_DEBUG 6 /* debug-level messages */
DECLARE_PER_CPU(char[256], ctcm_dbf_txt_buf);
enum ctcm_dbf_names { enum ctcm_dbf_names {
CTCM_DBF_SETUP, CTCM_DBF_SETUP,
CTCM_DBF_ERROR, CTCM_DBF_ERROR,
...@@ -67,6 +66,7 @@ extern struct ctcm_dbf_info ctcm_dbf[CTCM_DBF_INFOS]; ...@@ -67,6 +66,7 @@ extern struct ctcm_dbf_info ctcm_dbf[CTCM_DBF_INFOS];
int ctcm_register_dbf_views(void); int ctcm_register_dbf_views(void);
void ctcm_unregister_dbf_views(void); void ctcm_unregister_dbf_views(void);
void ctcm_dbf_longtext(enum ctcm_dbf_names dbf_nix, int level, char *text, ...);
static inline const char *strtail(const char *s, int n) static inline const char *strtail(const char *s, int n)
{ {
...@@ -74,12 +74,6 @@ static inline const char *strtail(const char *s, int n) ...@@ -74,12 +74,6 @@ static inline const char *strtail(const char *s, int n)
return (l > n) ? s + (l - n) : s; return (l > n) ? s + (l - n) : s;
} }
/* sort out levels early to avoid unnecessary sprintfs */
static inline int ctcm_dbf_passes(debug_info_t *dbf_grp, int level)
{
return (dbf_grp->level >= level);
}
#define CTCM_FUNTAIL strtail((char *)__func__, 16) #define CTCM_FUNTAIL strtail((char *)__func__, 16)
#define CTCM_DBF_TEXT(name, level, text) \ #define CTCM_DBF_TEXT(name, level, text) \
...@@ -94,16 +88,7 @@ static inline int ctcm_dbf_passes(debug_info_t *dbf_grp, int level) ...@@ -94,16 +88,7 @@ static inline int ctcm_dbf_passes(debug_info_t *dbf_grp, int level)
} while (0) } while (0)
#define CTCM_DBF_TEXT_(name, level, text...) \ #define CTCM_DBF_TEXT_(name, level, text...) \
do { \ ctcm_dbf_longtext(CTCM_DBF_##name, level, text)
if (ctcm_dbf_passes(ctcm_dbf[CTCM_DBF_##name].id, level)) { \
char *ctcm_dbf_txt_buf = \
get_cpu_var(ctcm_dbf_txt_buf); \
sprintf(ctcm_dbf_txt_buf, text); \
debug_text_event(ctcm_dbf[CTCM_DBF_##name].id, \
level, ctcm_dbf_txt_buf); \
put_cpu_var(ctcm_dbf_txt_buf); \
} \
} while (0)
/* /*
* cat : one of {setup, mpc_setup, trace, mpc_trace, error, mpc_error}. * cat : one of {setup, mpc_setup, trace, mpc_trace, error, mpc_error}.
...@@ -112,13 +97,13 @@ static inline int ctcm_dbf_passes(debug_info_t *dbf_grp, int level) ...@@ -112,13 +97,13 @@ static inline int ctcm_dbf_passes(debug_info_t *dbf_grp, int level)
*/ */
#define CTCM_DBF_DEV_NAME(cat, dev, text) \ #define CTCM_DBF_DEV_NAME(cat, dev, text) \
do { \ do { \
CTCM_DBF_TEXT_(cat, CTC_DBF_INFO, "%s(%s) : %s", \ CTCM_DBF_TEXT_(cat, CTC_DBF_INFO, "%s(%s) :- %s", \
CTCM_FUNTAIL, dev->name, text); \ CTCM_FUNTAIL, dev->name, text); \
} while (0) } while (0)
#define MPC_DBF_DEV_NAME(cat, dev, text) \ #define MPC_DBF_DEV_NAME(cat, dev, text) \
do { \ do { \
CTCM_DBF_TEXT_(MPC_##cat, CTC_DBF_INFO, "%s(%s) : %s", \ CTCM_DBF_TEXT_(MPC_##cat, CTC_DBF_INFO, "%s(%s) := %s", \
CTCM_FUNTAIL, dev->name, text); \ CTCM_FUNTAIL, dev->name, text); \
} while (0) } while (0)
...@@ -137,13 +122,13 @@ static inline int ctcm_dbf_passes(debug_info_t *dbf_grp, int level) ...@@ -137,13 +122,13 @@ static inline int ctcm_dbf_passes(debug_info_t *dbf_grp, int level)
*/ */
#define CTCM_DBF_DEV(cat, dev, text) \ #define CTCM_DBF_DEV(cat, dev, text) \
do { \ do { \
CTCM_DBF_TEXT_(cat, CTC_DBF_INFO, "%s(%p) : %s", \ CTCM_DBF_TEXT_(cat, CTC_DBF_INFO, "%s(%p) :-: %s", \
CTCM_FUNTAIL, dev, text); \ CTCM_FUNTAIL, dev, text); \
} while (0) } while (0)
#define MPC_DBF_DEV(cat, dev, text) \ #define MPC_DBF_DEV(cat, dev, text) \
do { \ do { \
CTCM_DBF_TEXT_(MPC_##cat, CTC_DBF_INFO, "%s(%p) : %s", \ CTCM_DBF_TEXT_(MPC_##cat, CTC_DBF_INFO, "%s(%p) :=: %s", \
CTCM_FUNTAIL, dev, text); \ CTCM_FUNTAIL, dev, text); \
} while (0) } while (0)
......
...@@ -190,7 +190,8 @@ static void ctcmpc_chx_send_sweep(fsm_instance *fsm, int event, void *arg); ...@@ -190,7 +190,8 @@ static void ctcmpc_chx_send_sweep(fsm_instance *fsm, int event, void *arg);
void ctcm_ccw_check_rc(struct channel *ch, int rc, char *msg) void ctcm_ccw_check_rc(struct channel *ch, int rc, char *msg)
{ {
CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR, CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR,
"ccw error %s (%s): %04x\n", ch->id, msg, rc); "%s(%s): %s: %04x\n",
CTCM_FUNTAIL, ch->id, msg, rc);
switch (rc) { switch (rc) {
case -EBUSY: case -EBUSY:
ctcm_pr_warn("%s (%s): Busy !\n", ch->id, msg); ctcm_pr_warn("%s (%s): Busy !\n", ch->id, msg);
...@@ -212,7 +213,7 @@ void ctcm_purge_skb_queue(struct sk_buff_head *q) ...@@ -212,7 +213,7 @@ void ctcm_purge_skb_queue(struct sk_buff_head *q)
{ {
struct sk_buff *skb; struct sk_buff *skb;
CTCM_DBF_TEXT(TRACE, 3, __FUNCTION__); CTCM_DBF_TEXT(TRACE, CTC_DBF_DEBUG, __func__);
while ((skb = skb_dequeue(q))) { while ((skb = skb_dequeue(q))) {
atomic_dec(&skb->users); atomic_dec(&skb->users);
...@@ -251,6 +252,8 @@ static void chx_txdone(fsm_instance *fi, int event, void *arg) ...@@ -251,6 +252,8 @@ static void chx_txdone(fsm_instance *fi, int event, void *arg)
unsigned long duration; unsigned long duration;
struct timespec done_stamp = current_kernel_time(); /* xtime */ struct timespec done_stamp = current_kernel_time(); /* xtime */
CTCM_PR_DEBUG("%s(%s): %s\n", __func__, ch->id, dev->name);
duration = duration =
(done_stamp.tv_sec - ch->prof.send_stamp.tv_sec) * 1000000 + (done_stamp.tv_sec - ch->prof.send_stamp.tv_sec) * 1000000 +
(done_stamp.tv_nsec - ch->prof.send_stamp.tv_nsec) / 1000; (done_stamp.tv_nsec - ch->prof.send_stamp.tv_nsec) / 1000;
...@@ -258,8 +261,9 @@ static void chx_txdone(fsm_instance *fi, int event, void *arg) ...@@ -258,8 +261,9 @@ static void chx_txdone(fsm_instance *fi, int event, void *arg)
ch->prof.tx_time = duration; ch->prof.tx_time = duration;
if (ch->irb->scsw.cmd.count != 0) if (ch->irb->scsw.cmd.count != 0)
ctcm_pr_debug("%s: TX not complete, remaining %d bytes\n", CTCM_DBF_TEXT_(TRACE, CTC_DBF_DEBUG,
dev->name, ch->irb->scsw.cmd.count); "%s(%s): TX not complete, remaining %d bytes",
CTCM_FUNTAIL, dev->name, ch->irb->scsw.cmd.count);
fsm_deltimer(&ch->timer); fsm_deltimer(&ch->timer);
while ((skb = skb_dequeue(&ch->io_queue))) { while ((skb = skb_dequeue(&ch->io_queue))) {
priv->stats.tx_packets++; priv->stats.tx_packets++;
...@@ -334,7 +338,8 @@ void ctcm_chx_txidle(fsm_instance *fi, int event, void *arg) ...@@ -334,7 +338,8 @@ void ctcm_chx_txidle(fsm_instance *fi, int event, void *arg)
struct net_device *dev = ch->netdev; struct net_device *dev = ch->netdev;
struct ctcm_priv *priv = dev->priv; struct ctcm_priv *priv = dev->priv;
CTCM_DBF_TEXT(TRACE, 6, __FUNCTION__); CTCM_PR_DEBUG("%s(%s): %s\n", __func__, ch->id, dev->name);
fsm_deltimer(&ch->timer); fsm_deltimer(&ch->timer);
fsm_newstate(fi, CTC_STATE_TXIDLE); fsm_newstate(fi, CTC_STATE_TXIDLE);
fsm_event(priv->fsm, DEV_EVENT_TXUP, ch->netdev); fsm_event(priv->fsm, DEV_EVENT_TXUP, ch->netdev);
...@@ -361,15 +366,17 @@ static void chx_rx(fsm_instance *fi, int event, void *arg) ...@@ -361,15 +366,17 @@ static void chx_rx(fsm_instance *fi, int event, void *arg)
fsm_deltimer(&ch->timer); fsm_deltimer(&ch->timer);
if (len < 8) { if (len < 8) {
ctcm_pr_debug("%s: got packet with length %d < 8\n", CTCM_DBF_TEXT_(TRACE, CTC_DBF_NOTICE,
dev->name, len); "%s(%s): got packet with length %d < 8\n",
CTCM_FUNTAIL, dev->name, len);
priv->stats.rx_dropped++; priv->stats.rx_dropped++;
priv->stats.rx_length_errors++; priv->stats.rx_length_errors++;
goto again; goto again;
} }
if (len > ch->max_bufsize) { if (len > ch->max_bufsize) {
ctcm_pr_debug("%s: got packet with length %d > %d\n", CTCM_DBF_TEXT_(TRACE, CTC_DBF_NOTICE,
dev->name, len, ch->max_bufsize); "%s(%s): got packet with length %d > %d\n",
CTCM_FUNTAIL, dev->name, len, ch->max_bufsize);
priv->stats.rx_dropped++; priv->stats.rx_dropped++;
priv->stats.rx_length_errors++; priv->stats.rx_length_errors++;
goto again; goto again;
...@@ -388,8 +395,9 @@ static void chx_rx(fsm_instance *fi, int event, void *arg) ...@@ -388,8 +395,9 @@ static void chx_rx(fsm_instance *fi, int event, void *arg)
break; break;
} }
if ((len < block_len) || (len > check_len)) { if ((len < block_len) || (len > check_len)) {
ctcm_pr_debug("%s: got block length %d != rx length %d\n", CTCM_DBF_TEXT_(TRACE, CTC_DBF_NOTICE,
dev->name, block_len, len); "%s(%s): got block length %d != rx length %d\n",
CTCM_FUNTAIL, dev->name, block_len, len);
if (do_debug) if (do_debug)
ctcmpc_dump_skb(skb, 0); ctcmpc_dump_skb(skb, 0);
...@@ -425,17 +433,23 @@ static void chx_rx(fsm_instance *fi, int event, void *arg) ...@@ -425,17 +433,23 @@ static void chx_rx(fsm_instance *fi, int event, void *arg)
*/ */
static void chx_firstio(fsm_instance *fi, int event, void *arg) static void chx_firstio(fsm_instance *fi, int event, void *arg)
{ {
struct channel *ch = arg;
int rc; int rc;
struct channel *ch = arg;
int fsmstate = fsm_getstate(fi);
CTCM_DBF_TEXT(TRACE, 6, __FUNCTION__); CTCM_DBF_TEXT_(TRACE, CTC_DBF_NOTICE,
"%s(%s) : %02x",
CTCM_FUNTAIL, ch->id, fsmstate);
if (fsm_getstate(fi) == CTC_STATE_TXIDLE) ch->sense_rc = 0; /* reset unit check report control */
ctcm_pr_debug("%s: remote side issued READ?, init.\n", ch->id); if (fsmstate == CTC_STATE_TXIDLE)
CTCM_DBF_TEXT_(TRACE, CTC_DBF_DEBUG,
"%s(%s): remote side issued READ?, init.\n",
CTCM_FUNTAIL, ch->id);
fsm_deltimer(&ch->timer); fsm_deltimer(&ch->timer);
if (ctcm_checkalloc_buffer(ch)) if (ctcm_checkalloc_buffer(ch))
return; return;
if ((fsm_getstate(fi) == CTC_STATE_SETUPWAIT) && if ((fsmstate == CTC_STATE_SETUPWAIT) &&
(ch->protocol == CTCM_PROTO_OS390)) { (ch->protocol == CTCM_PROTO_OS390)) {
/* OS/390 resp. z/OS */ /* OS/390 resp. z/OS */
if (CHANNEL_DIRECTION(ch->flags) == READ) { if (CHANNEL_DIRECTION(ch->flags) == READ) {
...@@ -451,7 +465,6 @@ static void chx_firstio(fsm_instance *fi, int event, void *arg) ...@@ -451,7 +465,6 @@ static void chx_firstio(fsm_instance *fi, int event, void *arg)
} }
return; return;
} }
/* /*
* Don't setup a timer for receiving the initial RX frame * Don't setup a timer for receiving the initial RX frame
* if in compatibility mode, since VM TCP delays the initial * if in compatibility mode, since VM TCP delays the initial
...@@ -505,11 +518,10 @@ static void chx_rxidle(fsm_instance *fi, int event, void *arg) ...@@ -505,11 +518,10 @@ static void chx_rxidle(fsm_instance *fi, int event, void *arg)
__u16 buflen; __u16 buflen;
int rc; int rc;
CTCM_DBF_TEXT(TRACE, 6, __FUNCTION__);
fsm_deltimer(&ch->timer); fsm_deltimer(&ch->timer);
buflen = *((__u16 *)ch->trans_skb->data); buflen = *((__u16 *)ch->trans_skb->data);
if (do_debug) CTCM_PR_DEBUG("%s: %s: Initial RX count = %d\n",
ctcm_pr_debug("%s: Initial RX count %d\n", dev->name, buflen); __func__, dev->name, buflen);
if (buflen >= CTCM_INITIAL_BLOCKLEN) { if (buflen >= CTCM_INITIAL_BLOCKLEN) {
if (ctcm_checkalloc_buffer(ch)) if (ctcm_checkalloc_buffer(ch))
...@@ -524,9 +536,9 @@ static void chx_rxidle(fsm_instance *fi, int event, void *arg) ...@@ -524,9 +536,9 @@ static void chx_rxidle(fsm_instance *fi, int event, void *arg)
} else } else
fsm_event(priv->fsm, DEV_EVENT_RXUP, dev); fsm_event(priv->fsm, DEV_EVENT_RXUP, dev);
} else { } else {
if (do_debug) CTCM_PR_DEBUG("%s: %s: Initial RX count %d not %d\n",
ctcm_pr_debug("%s: Initial RX count %d not %d\n", __func__, dev->name,
dev->name, buflen, CTCM_INITIAL_BLOCKLEN); buflen, CTCM_INITIAL_BLOCKLEN);
chx_firstio(fi, event, arg); chx_firstio(fi, event, arg);
} }
} }
...@@ -548,14 +560,12 @@ static void ctcm_chx_setmode(fsm_instance *fi, int event, void *arg) ...@@ -548,14 +560,12 @@ static void ctcm_chx_setmode(fsm_instance *fi, int event, void *arg)
fsm_deltimer(&ch->timer); fsm_deltimer(&ch->timer);
if (IS_MPC(ch)) { if (IS_MPC(ch)) {
timeout = 1500; timeout = 1500;
if (do_debug) CTCM_PR_DEBUG("enter %s: cp=%i ch=0x%p id=%s\n",
ctcm_pr_debug("ctcm enter: %s(): cp=%i ch=0x%p id=%s\n", __func__, smp_processor_id(), ch, ch->id);
__FUNCTION__, smp_processor_id(), ch, ch->id);
} }
fsm_addtimer(&ch->timer, timeout, CTC_EVENT_TIMER, ch); fsm_addtimer(&ch->timer, timeout, CTC_EVENT_TIMER, ch);
fsm_newstate(fi, CTC_STATE_SETUPWAIT); fsm_newstate(fi, CTC_STATE_SETUPWAIT);
if (do_debug_ccw && IS_MPC(ch)) CTCM_CCW_DUMP((char *)&ch->ccw[6], sizeof(struct ccw1) * 2);
ctcmpc_dumpit((char *)&ch->ccw[6], sizeof(struct ccw1) * 2);
if (event == CTC_EVENT_TIMER) /* only for timer not yet locked */ if (event == CTC_EVENT_TIMER) /* only for timer not yet locked */
spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags); spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags);
...@@ -584,23 +594,11 @@ static void ctcm_chx_setmode(fsm_instance *fi, int event, void *arg) ...@@ -584,23 +594,11 @@ static void ctcm_chx_setmode(fsm_instance *fi, int event, void *arg)
static void ctcm_chx_start(fsm_instance *fi, int event, void *arg) static void ctcm_chx_start(fsm_instance *fi, int event, void *arg)
{ {
struct channel *ch = arg; struct channel *ch = arg;
int rc;
struct net_device *dev;
unsigned long saveflags; unsigned long saveflags;
int rc;
CTCM_DBF_TEXT(TRACE, 5, __FUNCTION__); CTCM_DBF_TEXT_(SETUP, CTC_DBF_INFO, "%s(%s): %s",
if (ch == NULL) { CTCM_FUNTAIL, ch->id,
ctcm_pr_warn("chx_start ch=NULL\n");
return;
}
if (ch->netdev == NULL) {
ctcm_pr_warn("chx_start dev=NULL, id=%s\n", ch->id);
return;
}
dev = ch->netdev;
if (do_debug)
ctcm_pr_debug("%s: %s channel start\n", dev->name,
(CHANNEL_DIRECTION(ch->flags) == READ) ? "RX" : "TX"); (CHANNEL_DIRECTION(ch->flags) == READ) ? "RX" : "TX");
if (ch->trans_skb != NULL) { if (ch->trans_skb != NULL) {
...@@ -618,11 +616,12 @@ static void ctcm_chx_start(fsm_instance *fi, int event, void *arg) ...@@ -618,11 +616,12 @@ static void ctcm_chx_start(fsm_instance *fi, int event, void *arg)
ch->ccw[1].count = 0; ch->ccw[1].count = 0;
} }
if (ctcm_checkalloc_buffer(ch)) { if (ctcm_checkalloc_buffer(ch)) {
ctcm_pr_notice("%s: %s trans_skb allocation delayed " CTCM_DBF_TEXT_(TRACE, CTC_DBF_DEBUG,
"until first transfer\n", dev->name, "%s(%s): %s trans_skb alloc delayed "
"until first transfer",
CTCM_FUNTAIL, ch->id,
(CHANNEL_DIRECTION(ch->flags) == READ) ? "RX" : "TX"); (CHANNEL_DIRECTION(ch->flags) == READ) ? "RX" : "TX");
} }
ch->ccw[0].cmd_code = CCW_CMD_PREPARE; ch->ccw[0].cmd_code = CCW_CMD_PREPARE;
ch->ccw[0].flags = CCW_FLAG_SLI | CCW_FLAG_CC; ch->ccw[0].flags = CCW_FLAG_SLI | CCW_FLAG_CC;
ch->ccw[0].count = 0; ch->ccw[0].count = 0;
...@@ -661,7 +660,6 @@ static void ctcm_chx_haltio(fsm_instance *fi, int event, void *arg) ...@@ -661,7 +660,6 @@ static void ctcm_chx_haltio(fsm_instance *fi, int event, void *arg)
int rc; int rc;
int oldstate; int oldstate;
CTCM_DBF_TEXT(TRACE, 2, __FUNCTION__);
fsm_deltimer(&ch->timer); fsm_deltimer(&ch->timer);
if (IS_MPC(ch)) if (IS_MPC(ch))
fsm_deltimer(&ch->sweep_timer); fsm_deltimer(&ch->sweep_timer);
...@@ -684,7 +682,7 @@ static void ctcm_chx_haltio(fsm_instance *fi, int event, void *arg) ...@@ -684,7 +682,7 @@ static void ctcm_chx_haltio(fsm_instance *fi, int event, void *arg)
fsm_deltimer(&ch->timer); fsm_deltimer(&ch->timer);
if (event != CTC_EVENT_STOP) { if (event != CTC_EVENT_STOP) {
fsm_newstate(fi, oldstate); fsm_newstate(fi, oldstate);
ctcm_ccw_check_rc(ch, rc, (char *)__FUNCTION__); ctcm_ccw_check_rc(ch, rc, (char *)__func__);
} }
} }
} }
...@@ -703,7 +701,9 @@ static void ctcm_chx_cleanup(fsm_instance *fi, int state, ...@@ -703,7 +701,9 @@ static void ctcm_chx_cleanup(fsm_instance *fi, int state,
struct net_device *dev = ch->netdev; struct net_device *dev = ch->netdev;
struct ctcm_priv *priv = dev->priv; struct ctcm_priv *priv = dev->priv;
CTCM_DBF_TEXT(TRACE, 3, __FUNCTION__); CTCM_DBF_TEXT_(SETUP, CTC_DBF_NOTICE,
"%s(%s): %s[%d]\n",
CTCM_FUNTAIL, dev->name, ch->id, state);
fsm_deltimer(&ch->timer); fsm_deltimer(&ch->timer);
if (IS_MPC(ch)) if (IS_MPC(ch))
...@@ -743,7 +743,6 @@ static void ctcm_chx_cleanup(fsm_instance *fi, int state, ...@@ -743,7 +743,6 @@ static void ctcm_chx_cleanup(fsm_instance *fi, int state,
*/ */
static void ctcm_chx_stopped(fsm_instance *fi, int event, void *arg) static void ctcm_chx_stopped(fsm_instance *fi, int event, void *arg)
{ {
CTCM_DBF_TEXT(TRACE, 3, __FUNCTION__);
ctcm_chx_cleanup(fi, CTC_STATE_STOPPED, arg); ctcm_chx_cleanup(fi, CTC_STATE_STOPPED, arg);
} }
...@@ -771,7 +770,6 @@ static void ctcm_chx_stop(fsm_instance *fi, int event, void *arg) ...@@ -771,7 +770,6 @@ static void ctcm_chx_stop(fsm_instance *fi, int event, void *arg)
*/ */
static void ctcm_chx_fail(fsm_instance *fi, int event, void *arg) static void ctcm_chx_fail(fsm_instance *fi, int event, void *arg)
{ {
CTCM_DBF_TEXT(TRACE, 3, __FUNCTION__);
ctcm_chx_cleanup(fi, CTC_STATE_NOTOP, arg); ctcm_chx_cleanup(fi, CTC_STATE_NOTOP, arg);
} }
...@@ -809,8 +807,8 @@ static void ctcm_chx_setuperr(fsm_instance *fi, int event, void *arg) ...@@ -809,8 +807,8 @@ static void ctcm_chx_setuperr(fsm_instance *fi, int event, void *arg)
} }
CTCM_DBF_TEXT_(ERROR, CTC_DBF_CRIT, CTCM_DBF_TEXT_(ERROR, CTC_DBF_CRIT,
"%s : %s error during %s channel setup state=%s\n", "%s(%s) : %s error during %s channel setup state=%s\n",
dev->name, ctc_ch_event_names[event], CTCM_FUNTAIL, dev->name, ctc_ch_event_names[event],
(CHANNEL_DIRECTION(ch->flags) == READ) ? "RX" : "TX", (CHANNEL_DIRECTION(ch->flags) == READ) ? "RX" : "TX",
fsm_getstate_str(fi)); fsm_getstate_str(fi));
...@@ -838,10 +836,12 @@ static void ctcm_chx_restart(fsm_instance *fi, int event, void *arg) ...@@ -838,10 +836,12 @@ static void ctcm_chx_restart(fsm_instance *fi, int event, void *arg)
int oldstate; int oldstate;
int rc; int rc;
CTCM_DBF_TEXT(TRACE, CTC_DBF_NOTICE, __FUNCTION__); CTCM_DBF_TEXT_(TRACE, CTC_DBF_NOTICE,
"%s: %s[%d] of %s\n",
CTCM_FUNTAIL, ch->id, event, dev->name);
fsm_deltimer(&ch->timer); fsm_deltimer(&ch->timer);
ctcm_pr_debug("%s: %s channel restart\n", dev->name,
(CHANNEL_DIRECTION(ch->flags) == READ) ? "RX" : "TX");
fsm_addtimer(&ch->timer, CTCM_TIME_5_SEC, CTC_EVENT_TIMER, ch); fsm_addtimer(&ch->timer, CTCM_TIME_5_SEC, CTC_EVENT_TIMER, ch);
oldstate = fsm_getstate(fi); oldstate = fsm_getstate(fi);
fsm_newstate(fi, CTC_STATE_STARTWAIT); fsm_newstate(fi, CTC_STATE_STARTWAIT);
...@@ -876,13 +876,10 @@ static void ctcm_chx_rxiniterr(fsm_instance *fi, int event, void *arg) ...@@ -876,13 +876,10 @@ static void ctcm_chx_rxiniterr(fsm_instance *fi, int event, void *arg)
struct net_device *dev = ch->netdev; struct net_device *dev = ch->netdev;
struct ctcm_priv *priv = dev->priv; struct ctcm_priv *priv = dev->priv;
CTCM_DBF_TEXT(SETUP, 3, __FUNCTION__);
if (event == CTC_EVENT_TIMER) { if (event == CTC_EVENT_TIMER) {
if (!IS_MPCDEV(dev)) if (!IS_MPCDEV(dev))
/* TODO : check if MPC deletes timer somewhere */ /* TODO : check if MPC deletes timer somewhere */
fsm_deltimer(&ch->timer); fsm_deltimer(&ch->timer);
ctcm_pr_debug("%s: Timeout during RX init handshake\n",
dev->name);
if (ch->retry++ < 3) if (ch->retry++ < 3)
ctcm_chx_restart(fi, event, arg); ctcm_chx_restart(fi, event, arg);
else { else {
...@@ -907,9 +904,10 @@ static void ctcm_chx_rxinitfail(fsm_instance *fi, int event, void *arg) ...@@ -907,9 +904,10 @@ static void ctcm_chx_rxinitfail(fsm_instance *fi, int event, void *arg)
struct net_device *dev = ch->netdev; struct net_device *dev = ch->netdev;
struct ctcm_priv *priv = dev->priv; struct ctcm_priv *priv = dev->priv;
CTCM_DBF_TEXT(SETUP, 3, __FUNCTION__); CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR,
"%s(%s): RX %s busy, init. fail",
CTCM_FUNTAIL, dev->name, ch->id);
fsm_newstate(fi, CTC_STATE_RXERR); fsm_newstate(fi, CTC_STATE_RXERR);
ctcm_pr_warn("%s: RX busy. Initialization failed\n", dev->name);
fsm_event(priv->fsm, DEV_EVENT_RXDOWN, dev); fsm_event(priv->fsm, DEV_EVENT_RXDOWN, dev);
} }
...@@ -927,11 +925,10 @@ static void ctcm_chx_rxdisc(fsm_instance *fi, int event, void *arg) ...@@ -927,11 +925,10 @@ static void ctcm_chx_rxdisc(fsm_instance *fi, int event, void *arg)
struct net_device *dev = ch->netdev; struct net_device *dev = ch->netdev;
struct ctcm_priv *priv = dev->priv; struct ctcm_priv *priv = dev->priv;
CTCM_DBF_DEV_NAME(TRACE, dev, "Got remote disconnect, re-initializing"); CTCM_DBF_TEXT_(TRACE, CTC_DBF_NOTICE,
"%s: %s: remote disconnect - re-init ...",
CTCM_FUNTAIL, dev->name);
fsm_deltimer(&ch->timer); fsm_deltimer(&ch->timer);
if (do_debug)
ctcm_pr_debug("%s: Got remote disconnect, "
"re-initializing ...\n", dev->name);
/* /*
* Notify device statemachine * Notify device statemachine
*/ */
...@@ -961,8 +958,6 @@ static void ctcm_chx_txiniterr(fsm_instance *fi, int event, void *arg) ...@@ -961,8 +958,6 @@ static void ctcm_chx_txiniterr(fsm_instance *fi, int event, void *arg)
if (event == CTC_EVENT_TIMER) { if (event == CTC_EVENT_TIMER) {
fsm_deltimer(&ch->timer); fsm_deltimer(&ch->timer);
CTCM_DBF_DEV_NAME(ERROR, dev,
"Timeout during TX init handshake");
if (ch->retry++ < 3) if (ch->retry++ < 3)
ctcm_chx_restart(fi, event, arg); ctcm_chx_restart(fi, event, arg);
else { else {
...@@ -971,9 +966,8 @@ static void ctcm_chx_txiniterr(fsm_instance *fi, int event, void *arg) ...@@ -971,9 +966,8 @@ static void ctcm_chx_txiniterr(fsm_instance *fi, int event, void *arg)
} }
} else { } else {
CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR, CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR,
"%s : %s error during channel setup state=%s", "%s(%s): %s in %s", CTCM_FUNTAIL, ch->id,
dev->name, ctc_ch_event_names[event], ctc_ch_event_names[event], fsm_getstate_str(fi));
fsm_getstate_str(fi));
ctcm_pr_warn("%s: Error during TX init handshake\n", dev->name); ctcm_pr_warn("%s: Error during TX init handshake\n", dev->name);
} }
...@@ -993,15 +987,15 @@ static void ctcm_chx_txretry(fsm_instance *fi, int event, void *arg) ...@@ -993,15 +987,15 @@ static void ctcm_chx_txretry(fsm_instance *fi, int event, void *arg)
struct ctcm_priv *priv = dev->priv; struct ctcm_priv *priv = dev->priv;
struct sk_buff *skb; struct sk_buff *skb;
if (do_debug) CTCM_PR_DEBUG("Enter: %s: cp=%i ch=0x%p id=%s\n",
ctcm_pr_debug("ctcmpc enter: %s(): cp=%i ch=0x%p id=%s\n", __func__, smp_processor_id(), ch, ch->id);
__FUNCTION__, smp_processor_id(), ch, ch->id);
fsm_deltimer(&ch->timer); fsm_deltimer(&ch->timer);
if (ch->retry++ > 3) { if (ch->retry++ > 3) {
struct mpc_group *gptr = priv->mpcg; struct mpc_group *gptr = priv->mpcg;
ctcm_pr_debug("%s: TX retry failed, restarting channel\n", CTCM_DBF_TEXT_(TRACE, CTC_DBF_INFO,
dev->name); "%s: %s: retries exceeded",
CTCM_FUNTAIL, ch->id);
fsm_event(priv->fsm, DEV_EVENT_TXDOWN, dev); fsm_event(priv->fsm, DEV_EVENT_TXDOWN, dev);
/* call restart if not MPC or if MPC and mpcg fsm is ready. /* call restart if not MPC or if MPC and mpcg fsm is ready.
use gptr as mpc indicator */ use gptr as mpc indicator */
...@@ -1010,7 +1004,9 @@ static void ctcm_chx_txretry(fsm_instance *fi, int event, void *arg) ...@@ -1010,7 +1004,9 @@ static void ctcm_chx_txretry(fsm_instance *fi, int event, void *arg)
goto done; goto done;
} }
ctcm_pr_debug("%s: TX retry %d\n", dev->name, ch->retry); CTCM_DBF_TEXT_(TRACE, CTC_DBF_DEBUG,
"%s : %s: retry %d",
CTCM_FUNTAIL, ch->id, ch->retry);
skb = skb_peek(&ch->io_queue); skb = skb_peek(&ch->io_queue);
if (skb) { if (skb) {
int rc = 0; int rc = 0;
...@@ -1018,8 +1014,9 @@ static void ctcm_chx_txretry(fsm_instance *fi, int event, void *arg) ...@@ -1018,8 +1014,9 @@ static void ctcm_chx_txretry(fsm_instance *fi, int event, void *arg)
clear_normalized_cda(&ch->ccw[4]); clear_normalized_cda(&ch->ccw[4]);
ch->ccw[4].count = skb->len; ch->ccw[4].count = skb->len;
if (set_normalized_cda(&ch->ccw[4], skb->data)) { if (set_normalized_cda(&ch->ccw[4], skb->data)) {
ctcm_pr_debug("%s: IDAL alloc failed, chan restart\n", CTCM_DBF_TEXT_(TRACE, CTC_DBF_INFO,
dev->name); "%s: %s: IDAL alloc failed",
CTCM_FUNTAIL, ch->id);
fsm_event(priv->fsm, DEV_EVENT_TXDOWN, dev); fsm_event(priv->fsm, DEV_EVENT_TXDOWN, dev);
ctcm_chx_restart(fi, event, arg); ctcm_chx_restart(fi, event, arg);
goto done; goto done;
...@@ -1061,22 +1058,21 @@ static void ctcm_chx_iofatal(fsm_instance *fi, int event, void *arg) ...@@ -1061,22 +1058,21 @@ static void ctcm_chx_iofatal(fsm_instance *fi, int event, void *arg)
struct channel *ch = arg; struct channel *ch = arg;
struct net_device *dev = ch->netdev; struct net_device *dev = ch->netdev;
struct ctcm_priv *priv = dev->priv; struct ctcm_priv *priv = dev->priv;
int rd = CHANNEL_DIRECTION(ch->flags);
CTCM_DBF_TEXT(TRACE, 3, __FUNCTION__);
fsm_deltimer(&ch->timer); fsm_deltimer(&ch->timer);
ctcm_pr_warn("%s %s : unrecoverable channel error\n", CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR,
CTC_DRIVER_NAME, dev->name); "%s: %s: %s unrecoverable channel error",
CTCM_FUNTAIL, ch->id, rd == READ ? "RX" : "TX");
if (IS_MPC(ch)) { if (IS_MPC(ch)) {
priv->stats.tx_dropped++; priv->stats.tx_dropped++;
priv->stats.tx_errors++; priv->stats.tx_errors++;
} }
if (rd == READ) {
if (CHANNEL_DIRECTION(ch->flags) == READ) {
ctcm_pr_debug("%s: RX I/O error\n", dev->name);
fsm_newstate(fi, CTC_STATE_RXERR); fsm_newstate(fi, CTC_STATE_RXERR);
fsm_event(priv->fsm, DEV_EVENT_RXDOWN, dev); fsm_event(priv->fsm, DEV_EVENT_RXDOWN, dev);
} else { } else {
ctcm_pr_debug("%s: TX I/O error\n", dev->name);
fsm_newstate(fi, CTC_STATE_TXERR); fsm_newstate(fi, CTC_STATE_TXERR);
fsm_event(priv->fsm, DEV_EVENT_TXDOWN, dev); fsm_event(priv->fsm, DEV_EVENT_TXDOWN, dev);
} }
...@@ -1216,27 +1212,27 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg) ...@@ -1216,27 +1212,27 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg)
struct sk_buff *skb; struct sk_buff *skb;
int first = 1; int first = 1;
int i; int i;
struct timespec done_stamp;
__u32 data_space; __u32 data_space;
unsigned long duration; unsigned long duration;
struct sk_buff *peekskb; struct sk_buff *peekskb;
int rc; int rc;
struct th_header *header; struct th_header *header;
struct pdu *p_header; struct pdu *p_header;
struct timespec done_stamp = current_kernel_time(); /* xtime */
if (do_debug) CTCM_PR_DEBUG("Enter %s: %s cp:%i\n",
ctcm_pr_debug("%s cp:%i enter: %s()\n", __func__, dev->name, smp_processor_id());
dev->name, smp_processor_id(), __FUNCTION__);
done_stamp = current_kernel_time(); /* xtime */ duration =
duration = (done_stamp.tv_sec - ch->prof.send_stamp.tv_sec) * 1000000 (done_stamp.tv_sec - ch->prof.send_stamp.tv_sec) * 1000000 +
+ (done_stamp.tv_nsec - ch->prof.send_stamp.tv_nsec) / 1000; (done_stamp.tv_nsec - ch->prof.send_stamp.tv_nsec) / 1000;
if (duration > ch->prof.tx_time) if (duration > ch->prof.tx_time)
ch->prof.tx_time = duration; ch->prof.tx_time = duration;
if (ch->irb->scsw.cmd.count != 0) if (ch->irb->scsw.cmd.count != 0)
ctcm_pr_debug("%s: TX not complete, remaining %d bytes\n", CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_DEBUG,
dev->name, ch->irb->scsw.cmd.count); "%s(%s): TX not complete, remaining %d bytes",
CTCM_FUNTAIL, dev->name, ch->irb->scsw.cmd.count);
fsm_deltimer(&ch->timer); fsm_deltimer(&ch->timer);
while ((skb = skb_dequeue(&ch->io_queue))) { while ((skb = skb_dequeue(&ch->io_queue))) {
priv->stats.tx_packets++; priv->stats.tx_packets++;
...@@ -1250,7 +1246,6 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg) ...@@ -1250,7 +1246,6 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg)
} }
spin_lock(&ch->collect_lock); spin_lock(&ch->collect_lock);
clear_normalized_cda(&ch->ccw[4]); clear_normalized_cda(&ch->ccw[4]);
if ((ch->collect_len <= 0) || (grp->in_sweep != 0)) { if ((ch->collect_len <= 0) || (grp->in_sweep != 0)) {
spin_unlock(&ch->collect_lock); spin_unlock(&ch->collect_lock);
fsm_newstate(fi, CTC_STATE_TXIDLE); fsm_newstate(fi, CTC_STATE_TXIDLE);
...@@ -1269,17 +1264,13 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg) ...@@ -1269,17 +1264,13 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg)
if (ch->prof.maxcqueue < skb_queue_len(&ch->collect_queue)) if (ch->prof.maxcqueue < skb_queue_len(&ch->collect_queue))
ch->prof.maxcqueue = skb_queue_len(&ch->collect_queue); ch->prof.maxcqueue = skb_queue_len(&ch->collect_queue);
i = 0; i = 0;
p_header = NULL;
if (do_debug_data)
ctcm_pr_debug("ctcmpc: %s() building "
"trans_skb from collect_q \n", __FUNCTION__);
data_space = grp->group_max_buflen - TH_HEADER_LENGTH; data_space = grp->group_max_buflen - TH_HEADER_LENGTH;
if (do_debug_data) CTCM_PR_DBGDATA("%s: building trans_skb from collect_q"
ctcm_pr_debug("ctcmpc: %s() building trans_skb from collect_q" " data_space:%04x\n",
" data_space:%04x\n", __FUNCTION__, data_space); __func__, data_space);
p_header = NULL;
while ((skb = skb_dequeue(&ch->collect_queue))) { while ((skb = skb_dequeue(&ch->collect_queue))) {
memcpy(skb_put(ch->trans_skb, skb->len), skb->data, skb->len); memcpy(skb_put(ch->trans_skb, skb->len), skb->data, skb->len);
p_header = (struct pdu *) p_header = (struct pdu *)
...@@ -1290,15 +1281,12 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg) ...@@ -1290,15 +1281,12 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg)
else else
p_header->pdu_flag |= 0x20; p_header->pdu_flag |= 0x20;
if (do_debug_data) { CTCM_PR_DBGDATA("%s: trans_skb len:%04x \n",
ctcm_pr_debug("ctcmpc: %s()trans_skb len:%04x \n", __func__, ch->trans_skb->len);
__FUNCTION__, ch->trans_skb->len); CTCM_PR_DBGDATA("%s: pdu header and data for up"
ctcm_pr_debug("ctcmpc: %s() pdu header and data" " to 32 bytes sent to vtam\n", __func__);
" for up to 32 bytes sent to vtam\n", CTCM_D3_DUMP((char *)p_header, min_t(int, skb->len, 32));
__FUNCTION__);
ctcmpc_dumpit((char *)p_header,
min_t(int, skb->len, 32));
}
ch->collect_len -= skb->len; ch->collect_len -= skb->len;
data_space -= skb->len; data_space -= skb->len;
priv->stats.tx_packets++; priv->stats.tx_packets++;
...@@ -1314,46 +1302,38 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg) ...@@ -1314,46 +1302,38 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg)
if (p_header) if (p_header)
p_header->pdu_flag |= PDU_LAST; /*Say it's the last one*/ p_header->pdu_flag |= PDU_LAST; /*Say it's the last one*/
header = kzalloc(TH_HEADER_LENGTH, gfp_type()); header = kzalloc(TH_HEADER_LENGTH, gfp_type());
if (!header) { if (!header) {
printk(KERN_WARNING "ctcmpc: OUT OF MEMORY IN %s()"
": Data Lost \n", __FUNCTION__);
spin_unlock(&ch->collect_lock); spin_unlock(&ch->collect_lock);
fsm_event(priv->mpcg->fsm, MPCG_EVENT_INOP, dev); fsm_event(priv->mpcg->fsm, MPCG_EVENT_INOP, dev);
goto done; goto done;
} }
header->th_ch_flag = TH_HAS_PDU; /* Normal data */ header->th_ch_flag = TH_HAS_PDU; /* Normal data */
ch->th_seq_num++; ch->th_seq_num++;
header->th_seq_num = ch->th_seq_num; header->th_seq_num = ch->th_seq_num;
if (do_debug_data) CTCM_PR_DBGDATA("%s: ToVTAM_th_seq= %08x\n" ,
ctcm_pr_debug("%s: ToVTAM_th_seq= %08x\n" , __func__, ch->th_seq_num);
__FUNCTION__, ch->th_seq_num);
memcpy(skb_push(ch->trans_skb, TH_HEADER_LENGTH), header, memcpy(skb_push(ch->trans_skb, TH_HEADER_LENGTH), header,
TH_HEADER_LENGTH); /* put the TH on the packet */ TH_HEADER_LENGTH); /* put the TH on the packet */
kfree(header); kfree(header);
if (do_debug_data) { CTCM_PR_DBGDATA("%s: trans_skb len:%04x \n",
ctcm_pr_debug("ctcmpc: %s()trans_skb len:%04x \n", __func__, ch->trans_skb->len);
__FUNCTION__, ch->trans_skb->len); CTCM_PR_DBGDATA("%s: up-to-50 bytes of trans_skb "
"data to vtam from collect_q\n", __func__);
ctcm_pr_debug("ctcmpc: %s() up-to-50 bytes of trans_skb " CTCM_D3_DUMP((char *)ch->trans_skb->data,
"data to vtam from collect_q\n", __FUNCTION__);
ctcmpc_dumpit((char *)ch->trans_skb->data,
min_t(int, ch->trans_skb->len, 50)); min_t(int, ch->trans_skb->len, 50));
}
spin_unlock(&ch->collect_lock); spin_unlock(&ch->collect_lock);
clear_normalized_cda(&ch->ccw[1]); clear_normalized_cda(&ch->ccw[1]);
if (set_normalized_cda(&ch->ccw[1], ch->trans_skb->data)) { if (set_normalized_cda(&ch->ccw[1], ch->trans_skb->data)) {
dev_kfree_skb_any(ch->trans_skb); dev_kfree_skb_any(ch->trans_skb);
ch->trans_skb = NULL; ch->trans_skb = NULL;
printk(KERN_WARNING CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_ERROR,
"ctcmpc: %s()CCW failure - data lost\n", "%s: %s: IDAL alloc failed",
__FUNCTION__); CTCM_FUNTAIL, ch->id);
fsm_event(priv->mpcg->fsm, MPCG_EVENT_INOP, dev); fsm_event(priv->mpcg->fsm, MPCG_EVENT_INOP, dev);
return; return;
} }
...@@ -1373,7 +1353,6 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg) ...@@ -1373,7 +1353,6 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg)
} }
done: done:
ctcm_clear_busy(dev); ctcm_clear_busy(dev);
ctcm_pr_debug("ctcmpc exit: %s %s()\n", dev->name, __FUNCTION__);
return; return;
} }
...@@ -1396,23 +1375,22 @@ static void ctcmpc_chx_rx(fsm_instance *fi, int event, void *arg) ...@@ -1396,23 +1375,22 @@ static void ctcmpc_chx_rx(fsm_instance *fi, int event, void *arg)
unsigned long saveflags = 0; /* avoids compiler warning */ unsigned long saveflags = 0; /* avoids compiler warning */
int len = ch->max_bufsize - ch->irb->scsw.cmd.count; int len = ch->max_bufsize - ch->irb->scsw.cmd.count;
if (do_debug_data) { CTCM_PR_DEBUG("%s: %s: cp:%i %s maxbuf : %04x, len: %04x\n",
CTCM_DBF_TEXT_(TRACE, CTC_DBF_DEBUG, "mpc_ch_rx %s cp:%i %s\n", CTCM_FUNTAIL, dev->name, smp_processor_id(),
dev->name, smp_processor_id(), ch->id); ch->id, ch->max_bufsize, len);
CTCM_DBF_TEXT_(TRACE, CTC_DBF_DEBUG, "mpc_ch_rx: maxbuf: %04x "
"len: %04x\n", ch->max_bufsize, len);
}
fsm_deltimer(&ch->timer); fsm_deltimer(&ch->timer);
if (skb == NULL) { if (skb == NULL) {
ctcm_pr_debug("ctcmpc exit: %s() TRANS_SKB = NULL \n", CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
__FUNCTION__); "%s(%s): TRANS_SKB = NULL",
CTCM_FUNTAIL, dev->name);
goto again; goto again;
} }
if (len < TH_HEADER_LENGTH) { if (len < TH_HEADER_LENGTH) {
ctcm_pr_info("%s: got packet with invalid length %d\n", CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
dev->name, len); "%s(%s): packet length %d to short",
CTCM_FUNTAIL, dev->name, len);
priv->stats.rx_dropped++; priv->stats.rx_dropped++;
priv->stats.rx_length_errors++; priv->stats.rx_length_errors++;
} else { } else {
...@@ -1422,11 +1400,9 @@ static void ctcmpc_chx_rx(fsm_instance *fi, int event, void *arg) ...@@ -1422,11 +1400,9 @@ static void ctcmpc_chx_rx(fsm_instance *fi, int event, void *arg)
new_skb = __dev_alloc_skb(ch->max_bufsize, GFP_ATOMIC); new_skb = __dev_alloc_skb(ch->max_bufsize, GFP_ATOMIC);
if (new_skb == NULL) { if (new_skb == NULL) {
printk(KERN_INFO "ctcmpc:%s() NEW_SKB = NULL\n", CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
__FUNCTION__); "%s(%d): skb allocation failed",
printk(KERN_WARNING "ctcmpc: %s() MEMORY ALLOC FAILED" CTCM_FUNTAIL, dev->name);
" - DATA LOST - MPC FAILED\n",
__FUNCTION__);
fsm_event(priv->mpcg->fsm, MPCG_EVENT_INOP, dev); fsm_event(priv->mpcg->fsm, MPCG_EVENT_INOP, dev);
goto again; goto again;
} }
...@@ -1479,9 +1455,8 @@ static void ctcmpc_chx_rx(fsm_instance *fi, int event, void *arg) ...@@ -1479,9 +1455,8 @@ static void ctcmpc_chx_rx(fsm_instance *fi, int event, void *arg)
break; break;
} }
if (do_debug) CTCM_PR_DEBUG("Exit %s: %s, ch=0x%p, id=%s\n",
ctcm_pr_debug("ctcmpc exit : %s %s(): ch=0x%p id=%s\n", __func__, dev->name, ch, ch->id);
dev->name, __FUNCTION__, ch, ch->id);
} }
...@@ -1497,15 +1472,16 @@ static void ctcmpc_chx_firstio(fsm_instance *fi, int event, void *arg) ...@@ -1497,15 +1472,16 @@ static void ctcmpc_chx_firstio(fsm_instance *fi, int event, void *arg)
struct channel *ch = arg; struct channel *ch = arg;
struct net_device *dev = ch->netdev; struct net_device *dev = ch->netdev;
struct ctcm_priv *priv = dev->priv; struct ctcm_priv *priv = dev->priv;
if (do_debug) {
struct mpc_group *gptr = priv->mpcg; struct mpc_group *gptr = priv->mpcg;
ctcm_pr_debug("ctcmpc enter: %s(): ch=0x%p id=%s\n",
__FUNCTION__, ch, ch->id); CTCM_PR_DEBUG("Enter %s: id=%s, ch=0x%p\n",
ctcm_pr_debug("%s() %s chstate:%i grpstate:%i chprotocol:%i\n", __func__, ch->id, ch);
__FUNCTION__, ch->id, fsm_getstate(fi),
CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_INFO,
"%s: %s: chstate:%i, grpstate:%i, prot:%i\n",
CTCM_FUNTAIL, ch->id, fsm_getstate(fi),
fsm_getstate(gptr->fsm), ch->protocol); fsm_getstate(gptr->fsm), ch->protocol);
}
if (fsm_getstate(fi) == CTC_STATE_TXIDLE) if (fsm_getstate(fi) == CTC_STATE_TXIDLE)
MPC_DBF_DEV_NAME(TRACE, dev, "remote side issued READ? "); MPC_DBF_DEV_NAME(TRACE, dev, "remote side issued READ? ");
...@@ -1531,9 +1507,8 @@ static void ctcmpc_chx_firstio(fsm_instance *fi, int event, void *arg) ...@@ -1531,9 +1507,8 @@ static void ctcmpc_chx_firstio(fsm_instance *fi, int event, void *arg)
? CTC_STATE_RXINIT : CTC_STATE_TXINIT); ? CTC_STATE_RXINIT : CTC_STATE_TXINIT);
done: done:
if (do_debug) CTCM_PR_DEBUG("Exit %s: id=%s, ch=0x%p\n",
ctcm_pr_debug("ctcmpc exit : %s(): ch=0x%p id=%s\n", __func__, ch->id, ch);
__FUNCTION__, ch, ch->id);
return; return;
} }
...@@ -1556,11 +1531,8 @@ void ctcmpc_chx_rxidle(fsm_instance *fi, int event, void *arg) ...@@ -1556,11 +1531,8 @@ void ctcmpc_chx_rxidle(fsm_instance *fi, int event, void *arg)
unsigned long saveflags = 0; /* avoids compiler warning */ unsigned long saveflags = 0; /* avoids compiler warning */
fsm_deltimer(&ch->timer); fsm_deltimer(&ch->timer);
ctcm_pr_debug("%s cp:%i enter: %s()\n", CTCM_PR_DEBUG("%s: %s: %s: cp:%i, chstate:%i grpstate:%i\n",
dev->name, smp_processor_id(), __FUNCTION__); __func__, ch->id, dev->name, smp_processor_id(),
if (do_debug)
ctcm_pr_debug("%s() %s chstate:%i grpstate:%i\n",
__FUNCTION__, ch->id,
fsm_getstate(fi), fsm_getstate(grp->fsm)); fsm_getstate(fi), fsm_getstate(grp->fsm));
fsm_newstate(fi, CTC_STATE_RXIDLE); fsm_newstate(fi, CTC_STATE_RXIDLE);
...@@ -1575,9 +1547,7 @@ void ctcmpc_chx_rxidle(fsm_instance *fi, int event, void *arg) ...@@ -1575,9 +1547,7 @@ void ctcmpc_chx_rxidle(fsm_instance *fi, int event, void *arg)
skb_reset_tail_pointer(ch->trans_skb); skb_reset_tail_pointer(ch->trans_skb);
ch->trans_skb->len = 0; ch->trans_skb->len = 0;
ch->ccw[1].count = ch->max_bufsize; ch->ccw[1].count = ch->max_bufsize;
if (do_debug_ccw) CTCM_CCW_DUMP((char *)&ch->ccw[0], sizeof(struct ccw1) * 3);
ctcmpc_dumpit((char *)&ch->ccw[0],
sizeof(struct ccw1) * 3);
if (event == CTC_EVENT_START) if (event == CTC_EVENT_START)
/* see remark about conditional locking */ /* see remark about conditional locking */
spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags); spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags);
...@@ -1598,9 +1568,6 @@ void ctcmpc_chx_rxidle(fsm_instance *fi, int event, void *arg) ...@@ -1598,9 +1568,6 @@ void ctcmpc_chx_rxidle(fsm_instance *fi, int event, void *arg)
fsm_event(priv->fsm, DEV_EVENT_RXUP, dev); fsm_event(priv->fsm, DEV_EVENT_RXUP, dev);
done: done:
if (do_debug)
ctcm_pr_debug("ctcmpc exit: %s %s()\n",
dev->name, __FUNCTION__);
return; return;
} }
...@@ -1616,13 +1583,9 @@ static void ctcmpc_chx_attn(fsm_instance *fsm, int event, void *arg) ...@@ -1616,13 +1583,9 @@ static void ctcmpc_chx_attn(fsm_instance *fsm, int event, void *arg)
struct ctcm_priv *priv = dev->priv; struct ctcm_priv *priv = dev->priv;
struct mpc_group *grp = priv->mpcg; struct mpc_group *grp = priv->mpcg;
if (do_debug) { CTCM_PR_DEBUG("%s(%s): %s(ch=0x%p), cp=%i, ChStat:%s, GrpStat:%s\n",
ctcm_pr_debug("ctcmpc enter: %s(): cp=%i ch=0x%p id=%s" __func__, dev->name, ch->id, ch, smp_processor_id(),
"GrpState:%s ChState:%s\n", fsm_getstate_str(ch->fsm), fsm_getstate_str(grp->fsm));
__FUNCTION__, smp_processor_id(), ch, ch->id,
fsm_getstate_str(grp->fsm),
fsm_getstate_str(ch->fsm));
}
switch (fsm_getstate(grp->fsm)) { switch (fsm_getstate(grp->fsm)) {
case MPCG_STATE_XID2INITW: case MPCG_STATE_XID2INITW:
...@@ -1664,11 +1627,7 @@ static void ctcmpc_chx_attn(fsm_instance *fsm, int event, void *arg) ...@@ -1664,11 +1627,7 @@ static void ctcmpc_chx_attn(fsm_instance *fsm, int event, void *arg)
break; break;
} }
if (do_debug)
ctcm_pr_debug("ctcmpc exit : %s(): cp=%i ch=0x%p id=%s\n",
__FUNCTION__, smp_processor_id(), ch, ch->id);
return; return;
} }
/* /*
...@@ -1683,11 +1642,9 @@ static void ctcmpc_chx_attnbusy(fsm_instance *fsm, int event, void *arg) ...@@ -1683,11 +1642,9 @@ static void ctcmpc_chx_attnbusy(fsm_instance *fsm, int event, void *arg)
struct ctcm_priv *priv = dev->priv; struct ctcm_priv *priv = dev->priv;
struct mpc_group *grp = priv->mpcg; struct mpc_group *grp = priv->mpcg;
ctcm_pr_debug("ctcmpc enter: %s %s() %s \nGrpState:%s ChState:%s\n", CTCM_PR_DEBUG("%s(%s): %s\n ChState:%s GrpState:%s\n",
dev->name, __func__, dev->name, ch->id,
__FUNCTION__, ch->id, fsm_getstate_str(ch->fsm), fsm_getstate_str(grp->fsm));
fsm_getstate_str(grp->fsm),
fsm_getstate_str(ch->fsm));
fsm_deltimer(&ch->timer); fsm_deltimer(&ch->timer);
...@@ -1750,16 +1707,12 @@ static void ctcmpc_chx_attnbusy(fsm_instance *fsm, int event, void *arg) ...@@ -1750,16 +1707,12 @@ static void ctcmpc_chx_attnbusy(fsm_instance *fsm, int event, void *arg)
if (ch->in_mpcgroup) if (ch->in_mpcgroup)
fsm_event(grp->fsm, MPCG_EVENT_XID0DO, ch); fsm_event(grp->fsm, MPCG_EVENT_XID0DO, ch);
else else
printk(KERN_WARNING "ctcmpc: %s() Not all channels have" CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
" been added to group\n", __FUNCTION__); "%s(%s): channel %s not added to group",
CTCM_FUNTAIL, dev->name, ch->id);
done: done:
if (do_debug)
ctcm_pr_debug("ctcmpc exit : %s()%s ch=0x%p id=%s\n",
__FUNCTION__, dev->name, ch, ch->id);
return; return;
} }
/* /*
...@@ -1774,13 +1727,7 @@ static void ctcmpc_chx_resend(fsm_instance *fsm, int event, void *arg) ...@@ -1774,13 +1727,7 @@ static void ctcmpc_chx_resend(fsm_instance *fsm, int event, void *arg)
struct ctcm_priv *priv = dev->priv; struct ctcm_priv *priv = dev->priv;
struct mpc_group *grp = priv->mpcg; struct mpc_group *grp = priv->mpcg;
ctcm_pr_debug("ctcmpc enter: %s %s() %s \nGrpState:%s ChState:%s\n",
dev->name, __FUNCTION__, ch->id,
fsm_getstate_str(grp->fsm),
fsm_getstate_str(ch->fsm));
fsm_event(grp->fsm, MPCG_EVENT_XID0DO, ch); fsm_event(grp->fsm, MPCG_EVENT_XID0DO, ch);
return; return;
} }
...@@ -1802,19 +1749,16 @@ static void ctcmpc_chx_send_sweep(fsm_instance *fsm, int event, void *arg) ...@@ -1802,19 +1749,16 @@ static void ctcmpc_chx_send_sweep(fsm_instance *fsm, int event, void *arg)
int rc = 0; int rc = 0;
unsigned long saveflags = 0; unsigned long saveflags = 0;
if (do_debug) CTCM_PR_DEBUG("ctcmpc enter: %s(): cp=%i ch=0x%p id=%s\n",
ctcm_pr_debug("ctcmpc enter: %s(): cp=%i ch=0x%p id=%s\n", __func__, smp_processor_id(), ach, ach->id);
__FUNCTION__, smp_processor_id(), ach, ach->id);
if (grp->in_sweep == 0) if (grp->in_sweep == 0)
goto done; goto done;
if (do_debug_data) { CTCM_PR_DBGDATA("%s: 1: ToVTAM_th_seq= %08x\n" ,
ctcm_pr_debug("ctcmpc: %s() 1: ToVTAM_th_seq= %08x\n" , __func__, wch->th_seq_num);
__FUNCTION__, wch->th_seq_num); CTCM_PR_DBGDATA("%s: 1: FromVTAM_th_seq= %08x\n" ,
ctcm_pr_debug("ctcmpc: %s() 1: FromVTAM_th_seq= %08x\n" , __func__, rch->th_seq_num);
__FUNCTION__, rch->th_seq_num);
}
if (fsm_getstate(wch->fsm) != CTC_STATE_TXIDLE) { if (fsm_getstate(wch->fsm) != CTC_STATE_TXIDLE) {
/* give the previous IO time to complete */ /* give the previous IO time to complete */
...@@ -1853,11 +1797,9 @@ static void ctcmpc_chx_send_sweep(fsm_instance *fsm, int event, void *arg) ...@@ -1853,11 +1797,9 @@ static void ctcmpc_chx_send_sweep(fsm_instance *fsm, int event, void *arg)
header->sw.th_last_seq = wch->th_seq_num; header->sw.th_last_seq = wch->th_seq_num;
if (do_debug_ccw) CTCM_CCW_DUMP((char *)&wch->ccw[3], sizeof(struct ccw1) * 3);
ctcmpc_dumpit((char *)&wch->ccw[3], sizeof(struct ccw1) * 3); CTCM_PR_DBGDATA("%s: sweep packet\n", __func__);
CTCM_D3_DUMP((char *)header, TH_SWEEP_LENGTH);
ctcm_pr_debug("ctcmpc: %s() sweep packet\n", __FUNCTION__);
ctcmpc_dumpit((char *)header, TH_SWEEP_LENGTH);
fsm_addtimer(&wch->timer, CTCM_TIME_5_SEC, CTC_EVENT_TIMER, wch); fsm_addtimer(&wch->timer, CTCM_TIME_5_SEC, CTC_EVENT_TIMER, wch);
fsm_newstate(wch->fsm, CTC_STATE_TX); fsm_newstate(wch->fsm, CTC_STATE_TX);
...@@ -1876,19 +1818,13 @@ static void ctcmpc_chx_send_sweep(fsm_instance *fsm, int event, void *arg) ...@@ -1876,19 +1818,13 @@ static void ctcmpc_chx_send_sweep(fsm_instance *fsm, int event, void *arg)
ctcm_clear_busy_do(dev); ctcm_clear_busy_do(dev);
} }
if (do_debug_data) { CTCM_PR_DBGDATA("%s: To-/From-VTAM_th_seq = %08x/%08x\n" ,
ctcm_pr_debug("ctcmpc: %s()2: ToVTAM_th_seq= %08x\n" , __func__, wch->th_seq_num, rch->th_seq_num);
__FUNCTION__, wch->th_seq_num);
ctcm_pr_debug("ctcmpc: %s()2: FromVTAM_th_seq= %08x\n" ,
__FUNCTION__, rch->th_seq_num);
}
if (rc != 0) if (rc != 0)
ctcm_ccw_check_rc(wch, rc, "send sweep"); ctcm_ccw_check_rc(wch, rc, "send sweep");
done: done:
if (do_debug)
ctcm_pr_debug("ctcmpc exit: %s() %s\n", __FUNCTION__, ach->id);
return; return;
} }
...@@ -2149,9 +2085,8 @@ static void dev_action_stop(fsm_instance *fi, int event, void *arg) ...@@ -2149,9 +2085,8 @@ static void dev_action_stop(fsm_instance *fi, int event, void *arg)
struct channel *ch = priv->channel[direction]; struct channel *ch = priv->channel[direction];
fsm_event(ch->fsm, CTC_EVENT_STOP, ch); fsm_event(ch->fsm, CTC_EVENT_STOP, ch);
ch->th_seq_num = 0x00; ch->th_seq_num = 0x00;
if (do_debug) CTCM_PR_DEBUG("%s: CH_th_seq= %08x\n",
ctcm_pr_debug("ctcm: %s() CH_th_seq= %08x\n", __func__, ch->th_seq_num);
__FUNCTION__, ch->th_seq_num);
} }
if (IS_MPC(priv)) if (IS_MPC(priv))
fsm_newstate(priv->mpcg->fsm, MPCG_STATE_RESET); fsm_newstate(priv->mpcg->fsm, MPCG_STATE_RESET);
...@@ -2199,8 +2134,11 @@ static void dev_action_chup(fsm_instance *fi, int event, void *arg) ...@@ -2199,8 +2134,11 @@ static void dev_action_chup(fsm_instance *fi, int event, void *arg)
{ {
struct net_device *dev = arg; struct net_device *dev = arg;
struct ctcm_priv *priv = dev->priv; struct ctcm_priv *priv = dev->priv;
int dev_stat = fsm_getstate(fi);
CTCMY_DBF_DEV_NAME(SETUP, dev, ""); CTCM_DBF_TEXT_(SETUP, CTC_DBF_NOTICE,
"%s(%s): priv = %p [%d,%d]\n ", CTCM_FUNTAIL,
dev->name, dev->priv, dev_stat, event);
switch (fsm_getstate(fi)) { switch (fsm_getstate(fi)) {
case DEV_STATE_STARTWAIT_RXTX: case DEV_STATE_STARTWAIT_RXTX:
......
...@@ -84,20 +84,19 @@ void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb) ...@@ -84,20 +84,19 @@ void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb)
skb_pull(pskb, LL_HEADER_LENGTH); skb_pull(pskb, LL_HEADER_LENGTH);
if ((ch->protocol == CTCM_PROTO_S390) && if ((ch->protocol == CTCM_PROTO_S390) &&
(header->type != ETH_P_IP)) { (header->type != ETH_P_IP)) {
if (!(ch->logflags & LOG_FLAG_ILLEGALPKT)) { if (!(ch->logflags & LOG_FLAG_ILLEGALPKT)) {
ch->logflags |= LOG_FLAG_ILLEGALPKT;
/* /*
* Check packet type only if we stick strictly * Check packet type only if we stick strictly
* to S/390's protocol of OS390. This only * to S/390's protocol of OS390. This only
* supports IP. Otherwise allow any packet * supports IP. Otherwise allow any packet
* type. * type.
*/ */
ctcm_pr_warn("%s Illegal packet type 0x%04x " CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR,
"received, dropping\n", "%s(%s): Illegal packet type 0x%04x"
dev->name, header->type); " - dropping",
ch->logflags |= LOG_FLAG_ILLEGALPKT; CTCM_FUNTAIL, dev->name, header->type);
} }
priv->stats.rx_dropped++; priv->stats.rx_dropped++;
priv->stats.rx_frame_errors++; priv->stats.rx_frame_errors++;
return; return;
...@@ -105,11 +104,11 @@ void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb) ...@@ -105,11 +104,11 @@ void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb)
pskb->protocol = ntohs(header->type); pskb->protocol = ntohs(header->type);
if (header->length <= LL_HEADER_LENGTH) { if (header->length <= LL_HEADER_LENGTH) {
if (!(ch->logflags & LOG_FLAG_ILLEGALSIZE)) { if (!(ch->logflags & LOG_FLAG_ILLEGALSIZE)) {
ctcm_pr_warn( CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR,
"%s Illegal packet size %d " "%s(%s): Illegal packet size %d(%d,%d)"
"received (MTU=%d blocklen=%d), " "- dropping",
"dropping\n", dev->name, header->length, CTCM_FUNTAIL, dev->name,
dev->mtu, len); header->length, dev->mtu, len);
ch->logflags |= LOG_FLAG_ILLEGALSIZE; ch->logflags |= LOG_FLAG_ILLEGALSIZE;
} }
...@@ -122,9 +121,9 @@ void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb) ...@@ -122,9 +121,9 @@ void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb)
if ((header->length > skb_tailroom(pskb)) || if ((header->length > skb_tailroom(pskb)) ||
(header->length > len)) { (header->length > len)) {
if (!(ch->logflags & LOG_FLAG_OVERRUN)) { if (!(ch->logflags & LOG_FLAG_OVERRUN)) {
ctcm_pr_warn( CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR,
"%s Illegal packet size %d (beyond the" "%s(%s): Packet size %d (overrun)"
" end of received data), dropping\n", " - dropping", CTCM_FUNTAIL,
dev->name, header->length); dev->name, header->length);
ch->logflags |= LOG_FLAG_OVERRUN; ch->logflags |= LOG_FLAG_OVERRUN;
} }
...@@ -139,9 +138,9 @@ void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb) ...@@ -139,9 +138,9 @@ void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb)
skb = dev_alloc_skb(pskb->len); skb = dev_alloc_skb(pskb->len);
if (!skb) { if (!skb) {
if (!(ch->logflags & LOG_FLAG_NOMEM)) { if (!(ch->logflags & LOG_FLAG_NOMEM)) {
ctcm_pr_warn( CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR,
"%s Out of memory in ctcm_unpack_skb\n", "%s(%s): MEMORY allocation error",
dev->name); CTCM_FUNTAIL, dev->name);
ch->logflags |= LOG_FLAG_NOMEM; ch->logflags |= LOG_FLAG_NOMEM;
} }
priv->stats.rx_dropped++; priv->stats.rx_dropped++;
...@@ -184,7 +183,7 @@ void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb) ...@@ -184,7 +183,7 @@ void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb)
*/ */
static void channel_free(struct channel *ch) static void channel_free(struct channel *ch)
{ {
CTCM_DBF_TEXT(TRACE, 2, __FUNCTION__); CTCM_DBF_TEXT_(SETUP, CTC_DBF_INFO, "%s(%s)", CTCM_FUNTAIL, ch->id);
ch->flags &= ~CHANNEL_FLAGS_INUSE; ch->flags &= ~CHANNEL_FLAGS_INUSE;
fsm_newstate(ch->fsm, CTC_STATE_IDLE); fsm_newstate(ch->fsm, CTC_STATE_IDLE);
} }
...@@ -251,19 +250,12 @@ static struct channel *channel_get(enum channel_types type, ...@@ -251,19 +250,12 @@ static struct channel *channel_get(enum channel_types type,
{ {
struct channel *ch = channels; struct channel *ch = channels;
if (do_debug) {
char buf[64];
sprintf(buf, "%s(%d, %s, %d)\n",
CTCM_FUNTAIL, type, id, direction);
CTCM_DBF_TEXT(TRACE, CTC_DBF_INFO, buf);
}
while (ch && (strncmp(ch->id, id, CTCM_ID_SIZE) || (ch->type != type))) while (ch && (strncmp(ch->id, id, CTCM_ID_SIZE) || (ch->type != type)))
ch = ch->next; ch = ch->next;
if (!ch) { if (!ch) {
char buf[64]; CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR,
sprintf(buf, "%s(%d, %s, %d) not found in channel list\n", "%s(%d, %s, %d) not found in channel list\n",
CTCM_FUNTAIL, type, id, direction); CTCM_FUNTAIL, type, id, direction);
CTCM_DBF_TEXT(ERROR, CTC_DBF_ERROR, buf);
} else { } else {
if (ch->flags & CHANNEL_FLAGS_INUSE) if (ch->flags & CHANNEL_FLAGS_INUSE)
ch = NULL; ch = NULL;
...@@ -283,7 +275,8 @@ static long ctcm_check_irb_error(struct ccw_device *cdev, struct irb *irb) ...@@ -283,7 +275,8 @@ static long ctcm_check_irb_error(struct ccw_device *cdev, struct irb *irb)
if (!IS_ERR(irb)) if (!IS_ERR(irb))
return 0; return 0;
CTCM_DBF_TEXT_(ERROR, CTC_DBF_WARN, "irb error %ld on device %s\n", CTCM_DBF_TEXT_(ERROR, CTC_DBF_WARN,
"irb error %ld on device %s\n",
PTR_ERR(irb), cdev->dev.bus_id); PTR_ERR(irb), cdev->dev.bus_id);
switch (PTR_ERR(irb)) { switch (PTR_ERR(irb)) {
...@@ -307,58 +300,85 @@ static long ctcm_check_irb_error(struct ccw_device *cdev, struct irb *irb) ...@@ -307,58 +300,85 @@ static long ctcm_check_irb_error(struct ccw_device *cdev, struct irb *irb)
* ch The channel, the sense code belongs to. * ch The channel, the sense code belongs to.
* sense The sense code to inspect. * sense The sense code to inspect.
*/ */
static inline void ccw_unit_check(struct channel *ch, unsigned char sense) static inline void ccw_unit_check(struct channel *ch, __u8 sense)
{ {
CTCM_DBF_TEXT(TRACE, 5, __FUNCTION__); CTCM_DBF_TEXT_(TRACE, CTC_DBF_DEBUG,
"%s(%s): %02x",
CTCM_FUNTAIL, ch->id, sense);
if (sense & SNS0_INTERVENTION_REQ) { if (sense & SNS0_INTERVENTION_REQ) {
if (sense & 0x01) { if (sense & 0x01) {
ctcm_pr_debug("%s: Interface disc. or Sel. reset " if (ch->sense_rc != 0x01) {
"(remote)\n", ch->id); ctcm_pr_debug("%s: Interface disc. or Sel. "
"reset (remote)\n", ch->id);
ch->sense_rc = 0x01;
}
fsm_event(ch->fsm, CTC_EVENT_UC_RCRESET, ch); fsm_event(ch->fsm, CTC_EVENT_UC_RCRESET, ch);
} else { } else {
ctcm_pr_debug("%s: System reset (remote)\n", ch->id); if (ch->sense_rc != SNS0_INTERVENTION_REQ) {
ctcm_pr_debug("%s: System reset (remote)\n",
ch->id);
ch->sense_rc = SNS0_INTERVENTION_REQ;
}
fsm_event(ch->fsm, CTC_EVENT_UC_RSRESET, ch); fsm_event(ch->fsm, CTC_EVENT_UC_RSRESET, ch);
} }
} else if (sense & SNS0_EQUIPMENT_CHECK) { } else if (sense & SNS0_EQUIPMENT_CHECK) {
if (sense & SNS0_BUS_OUT_CHECK) { if (sense & SNS0_BUS_OUT_CHECK) {
ctcm_pr_warn("%s: Hardware malfunction (remote)\n", if (ch->sense_rc != SNS0_BUS_OUT_CHECK) {
ch->id); CTCM_DBF_TEXT_(TRACE, CTC_DBF_WARN,
"%s(%s): remote HW error %02x",
CTCM_FUNTAIL, ch->id, sense);
ch->sense_rc = SNS0_BUS_OUT_CHECK;
}
fsm_event(ch->fsm, CTC_EVENT_UC_HWFAIL, ch); fsm_event(ch->fsm, CTC_EVENT_UC_HWFAIL, ch);
} else { } else {
ctcm_pr_warn("%s: Read-data parity error (remote)\n", if (ch->sense_rc != SNS0_EQUIPMENT_CHECK) {
ch->id); CTCM_DBF_TEXT_(TRACE, CTC_DBF_WARN,
"%s(%s): remote read parity error %02x",
CTCM_FUNTAIL, ch->id, sense);
ch->sense_rc = SNS0_EQUIPMENT_CHECK;
}
fsm_event(ch->fsm, CTC_EVENT_UC_RXPARITY, ch); fsm_event(ch->fsm, CTC_EVENT_UC_RXPARITY, ch);
} }
} else if (sense & SNS0_BUS_OUT_CHECK) { } else if (sense & SNS0_BUS_OUT_CHECK) {
if (sense & 0x04) { if (ch->sense_rc != SNS0_BUS_OUT_CHECK) {
ctcm_pr_warn("%s: Data-streaming timeout)\n", ch->id); CTCM_DBF_TEXT_(TRACE, CTC_DBF_WARN,
"%s(%s): BUS OUT error %02x",
CTCM_FUNTAIL, ch->id, sense);
ch->sense_rc = SNS0_BUS_OUT_CHECK;
}
if (sense & 0x04) /* data-streaming timeout */
fsm_event(ch->fsm, CTC_EVENT_UC_TXTIMEOUT, ch); fsm_event(ch->fsm, CTC_EVENT_UC_TXTIMEOUT, ch);
} else { else /* Data-transfer parity error */
ctcm_pr_warn("%s: Data-transfer parity error\n",
ch->id);
fsm_event(ch->fsm, CTC_EVENT_UC_TXPARITY, ch); fsm_event(ch->fsm, CTC_EVENT_UC_TXPARITY, ch);
}
} else if (sense & SNS0_CMD_REJECT) { } else if (sense & SNS0_CMD_REJECT) {
ctcm_pr_warn("%s: Command reject\n", ch->id); if (ch->sense_rc != SNS0_CMD_REJECT) {
CTCM_DBF_TEXT_(TRACE, CTC_DBF_WARN,
"%s(%s): Command rejected",
CTCM_FUNTAIL, ch->id);
ch->sense_rc = SNS0_CMD_REJECT;
}
} else if (sense == 0) { } else if (sense == 0) {
ctcm_pr_debug("%s: Unit check ZERO\n", ch->id); CTCM_DBF_TEXT_(TRACE, CTC_DBF_WARN,
"%s(%s): Unit check ZERO",
CTCM_FUNTAIL, ch->id);
fsm_event(ch->fsm, CTC_EVENT_UC_ZERO, ch); fsm_event(ch->fsm, CTC_EVENT_UC_ZERO, ch);
} else { } else {
ctcm_pr_warn("%s: Unit Check with sense code: %02x\n", CTCM_DBF_TEXT_(TRACE, CTC_DBF_WARN,
ch->id, sense); "%s(%s): Unit check code %02x unknown",
CTCM_FUNTAIL, ch->id, sense);
fsm_event(ch->fsm, CTC_EVENT_UC_UNKNOWN, ch); fsm_event(ch->fsm, CTC_EVENT_UC_UNKNOWN, ch);
} }
} }
int ctcm_ch_alloc_buffer(struct channel *ch) int ctcm_ch_alloc_buffer(struct channel *ch)
{ {
CTCM_DBF_TEXT(TRACE, 5, __FUNCTION__);
clear_normalized_cda(&ch->ccw[1]); clear_normalized_cda(&ch->ccw[1]);
ch->trans_skb = __dev_alloc_skb(ch->max_bufsize, GFP_ATOMIC | GFP_DMA); ch->trans_skb = __dev_alloc_skb(ch->max_bufsize, GFP_ATOMIC | GFP_DMA);
if (ch->trans_skb == NULL) { if (ch->trans_skb == NULL) {
ctcm_pr_warn("%s: Couldn't alloc %s trans_skb\n", CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR,
ch->id, "%s(%s): %s trans_skb allocation error",
CTCM_FUNTAIL, ch->id,
(CHANNEL_DIRECTION(ch->flags) == READ) ? "RX" : "TX"); (CHANNEL_DIRECTION(ch->flags) == READ) ? "RX" : "TX");
return -ENOMEM; return -ENOMEM;
} }
...@@ -367,9 +387,9 @@ int ctcm_ch_alloc_buffer(struct channel *ch) ...@@ -367,9 +387,9 @@ int ctcm_ch_alloc_buffer(struct channel *ch)
if (set_normalized_cda(&ch->ccw[1], ch->trans_skb->data)) { if (set_normalized_cda(&ch->ccw[1], ch->trans_skb->data)) {
dev_kfree_skb(ch->trans_skb); dev_kfree_skb(ch->trans_skb);
ch->trans_skb = NULL; ch->trans_skb = NULL;
ctcm_pr_warn("%s: set_normalized_cda for %s " CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR,
"trans_skb failed, dropping packets\n", "%s(%s): %s set norm_cda failed",
ch->id, CTCM_FUNTAIL, ch->id,
(CHANNEL_DIRECTION(ch->flags) == READ) ? "RX" : "TX"); (CHANNEL_DIRECTION(ch->flags) == READ) ? "RX" : "TX");
return -ENOMEM; return -ENOMEM;
} }
...@@ -516,7 +536,7 @@ static int ctcm_transmit_skb(struct channel *ch, struct sk_buff *skb) ...@@ -516,7 +536,7 @@ static int ctcm_transmit_skb(struct channel *ch, struct sk_buff *skb)
atomic_dec(&skb->users); atomic_dec(&skb->users);
skb_pull(skb, LL_HEADER_LENGTH + 2); skb_pull(skb, LL_HEADER_LENGTH + 2);
ctcm_clear_busy(ch->netdev); ctcm_clear_busy(ch->netdev);
return -EBUSY; return -ENOMEM;
} }
skb_reset_tail_pointer(ch->trans_skb); skb_reset_tail_pointer(ch->trans_skb);
...@@ -570,15 +590,12 @@ static void ctcmpc_send_sweep_req(struct channel *rch) ...@@ -570,15 +590,12 @@ static void ctcmpc_send_sweep_req(struct channel *rch)
struct th_sweep *header; struct th_sweep *header;
struct sk_buff *sweep_skb; struct sk_buff *sweep_skb;
struct channel *ch; struct channel *ch;
int rc = 0; /* int rc = 0; */
priv = dev->priv; priv = dev->priv;
grp = priv->mpcg; grp = priv->mpcg;
ch = priv->channel[WRITE]; ch = priv->channel[WRITE];
if (do_debug)
MPC_DBF_DEV_NAME(TRACE, dev, ch->id);
/* sweep processing is not complete until response and request */ /* sweep processing is not complete until response and request */
/* has completed for all read channels in group */ /* has completed for all read channels in group */
if (grp->in_sweep == 0) { if (grp->in_sweep == 0) {
...@@ -590,17 +607,16 @@ static void ctcmpc_send_sweep_req(struct channel *rch) ...@@ -590,17 +607,16 @@ static void ctcmpc_send_sweep_req(struct channel *rch)
sweep_skb = __dev_alloc_skb(MPC_BUFSIZE_DEFAULT, GFP_ATOMIC|GFP_DMA); sweep_skb = __dev_alloc_skb(MPC_BUFSIZE_DEFAULT, GFP_ATOMIC|GFP_DMA);
if (sweep_skb == NULL) { if (sweep_skb == NULL) {
printk(KERN_INFO "Couldn't alloc sweep_skb\n"); /* rc = -ENOMEM; */
rc = -ENOMEM; goto nomem;
goto done;
} }
header = kmalloc(TH_SWEEP_LENGTH, gfp_type()); header = kmalloc(TH_SWEEP_LENGTH, gfp_type());
if (!header) { if (!header) {
dev_kfree_skb_any(sweep_skb); dev_kfree_skb_any(sweep_skb);
rc = -ENOMEM; /* rc = -ENOMEM; */
goto done; goto nomem;
} }
header->th.th_seg = 0x00 ; header->th.th_seg = 0x00 ;
...@@ -621,12 +637,10 @@ static void ctcmpc_send_sweep_req(struct channel *rch) ...@@ -621,12 +637,10 @@ static void ctcmpc_send_sweep_req(struct channel *rch)
return; return;
done: nomem:
if (rc != 0) {
grp->in_sweep = 0; grp->in_sweep = 0;
ctcm_clear_busy(dev); ctcm_clear_busy(dev);
fsm_event(grp->fsm, MPCG_EVENT_INOP, dev); fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
}
return; return;
} }
...@@ -648,10 +662,8 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb) ...@@ -648,10 +662,8 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb)
unsigned long saveflags = 0; /* avoids compiler warning */ unsigned long saveflags = 0; /* avoids compiler warning */
__u16 block_len; __u16 block_len;
if (do_debug) CTCM_PR_DEBUG("Enter %s: %s, cp=%i ch=0x%p id=%s state=%s\n",
ctcm_pr_debug( __func__, dev->name, smp_processor_id(), ch,
"ctcm enter: %s(): %s cp=%i ch=0x%p id=%s state=%s\n",
__FUNCTION__, dev->name, smp_processor_id(), ch,
ch->id, fsm_getstate_str(ch->fsm)); ch->id, fsm_getstate_str(ch->fsm));
if ((fsm_getstate(ch->fsm) != CTC_STATE_TXIDLE) || grp->in_sweep) { if ((fsm_getstate(ch->fsm) != CTC_STATE_TXIDLE) || grp->in_sweep) {
...@@ -660,14 +672,8 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb) ...@@ -660,14 +672,8 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb)
p_header = kmalloc(PDU_HEADER_LENGTH, gfp_type()); p_header = kmalloc(PDU_HEADER_LENGTH, gfp_type());
if (!p_header) { if (!p_header) {
printk(KERN_WARNING "ctcm: OUT OF MEMORY IN %s():"
" Data Lost \n", __FUNCTION__);
atomic_dec(&skb->users);
dev_kfree_skb_any(skb);
spin_unlock_irqrestore(&ch->collect_lock, saveflags); spin_unlock_irqrestore(&ch->collect_lock, saveflags);
fsm_event(priv->mpcg->fsm, MPCG_EVENT_INOP, dev); goto nomem_exit;
goto done;
} }
p_header->pdu_offset = skb->len; p_header->pdu_offset = skb->len;
...@@ -682,13 +688,10 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb) ...@@ -682,13 +688,10 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb)
memcpy(skb_push(skb, PDU_HEADER_LENGTH), p_header, memcpy(skb_push(skb, PDU_HEADER_LENGTH), p_header,
PDU_HEADER_LENGTH); PDU_HEADER_LENGTH);
if (do_debug_data) { CTCM_PR_DEBUG("%s(%s): Put on collect_q - skb len: %04x \n"
ctcm_pr_debug("ctcm: %s() Putting on collect_q" "pdu header and data for up to 32 bytes:\n",
" - skb len: %04x \n", __FUNCTION__, skb->len); __func__, dev->name, skb->len);
ctcm_pr_debug("ctcm: %s() pdu header and data" CTCM_D3_DUMP((char *)skb->data, min_t(int, 32, skb->len));
" for up to 32 bytes\n", __FUNCTION__);
ctcmpc_dump32((char *)skb->data, skb->len);
}
skb_queue_tail(&ch->collect_queue, skb); skb_queue_tail(&ch->collect_queue, skb);
ch->collect_len += skb->len; ch->collect_len += skb->len;
...@@ -713,12 +716,7 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb) ...@@ -713,12 +716,7 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb)
if (hi) { if (hi) {
nskb = __dev_alloc_skb(skb->len, GFP_ATOMIC | GFP_DMA); nskb = __dev_alloc_skb(skb->len, GFP_ATOMIC | GFP_DMA);
if (!nskb) { if (!nskb) {
printk(KERN_WARNING "ctcm: %s() OUT OF MEMORY" goto nomem_exit;
"- Data Lost \n", __FUNCTION__);
atomic_dec(&skb->users);
dev_kfree_skb_any(skb);
fsm_event(priv->mpcg->fsm, MPCG_EVENT_INOP, dev);
goto done;
} else { } else {
memcpy(skb_put(nskb, skb->len), skb->data, skb->len); memcpy(skb_put(nskb, skb->len), skb->data, skb->len);
atomic_inc(&nskb->users); atomic_inc(&nskb->users);
...@@ -730,15 +728,8 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb) ...@@ -730,15 +728,8 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb)
p_header = kmalloc(PDU_HEADER_LENGTH, gfp_type()); p_header = kmalloc(PDU_HEADER_LENGTH, gfp_type());
if (!p_header) { if (!p_header)
printk(KERN_WARNING "ctcm: %s() OUT OF MEMORY" goto nomem_exit;
": Data Lost \n", __FUNCTION__);
atomic_dec(&skb->users);
dev_kfree_skb_any(skb);
fsm_event(priv->mpcg->fsm, MPCG_EVENT_INOP, dev);
goto done;
}
p_header->pdu_offset = skb->len; p_header->pdu_offset = skb->len;
p_header->pdu_proto = 0x01; p_header->pdu_proto = 0x01;
...@@ -768,15 +759,8 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb) ...@@ -768,15 +759,8 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb)
ch->prof.txlen += skb->len - PDU_HEADER_LENGTH; ch->prof.txlen += skb->len - PDU_HEADER_LENGTH;
header = kmalloc(TH_HEADER_LENGTH, gfp_type()); header = kmalloc(TH_HEADER_LENGTH, gfp_type());
if (!header)
if (!header) { goto nomem_exit;
printk(KERN_WARNING "ctcm: %s() OUT OF MEMORY: Data Lost \n",
__FUNCTION__);
atomic_dec(&skb->users);
dev_kfree_skb_any(skb);
fsm_event(priv->mpcg->fsm, MPCG_EVENT_INOP, dev);
goto done;
}
header->th_seg = 0x00; header->th_seg = 0x00;
header->th_ch_flag = TH_HAS_PDU; /* Normal data */ header->th_ch_flag = TH_HAS_PDU; /* Normal data */
...@@ -785,41 +769,31 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb) ...@@ -785,41 +769,31 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb)
ch->th_seq_num++; ch->th_seq_num++;
header->th_seq_num = ch->th_seq_num; header->th_seq_num = ch->th_seq_num;
if (do_debug_data) CTCM_PR_DBGDATA("%s(%s) ToVTAM_th_seq= %08x\n" ,
ctcm_pr_debug("ctcm: %s() ToVTAM_th_seq= %08x\n" , __func__, dev->name, ch->th_seq_num);
__FUNCTION__, ch->th_seq_num);
/* put the TH on the packet */ /* put the TH on the packet */
memcpy(skb_push(skb, TH_HEADER_LENGTH), header, TH_HEADER_LENGTH); memcpy(skb_push(skb, TH_HEADER_LENGTH), header, TH_HEADER_LENGTH);
kfree(header); kfree(header);
if (do_debug_data) { CTCM_PR_DBGDATA("%s(%s): skb len: %04x\n - pdu header and data for "
ctcm_pr_debug("ctcm: %s(): skb len: %04x \n", "up to 32 bytes sent to vtam:\n",
__FUNCTION__, skb->len); __func__, dev->name, skb->len);
ctcm_pr_debug("ctcm: %s(): pdu header and data for up to 32 " CTCM_D3_DUMP((char *)skb->data, min_t(int, 32, skb->len));
"bytes sent to vtam\n", __FUNCTION__);
ctcmpc_dump32((char *)skb->data, skb->len);
}
ch->ccw[4].count = skb->len; ch->ccw[4].count = skb->len;
if (set_normalized_cda(&ch->ccw[4], skb->data)) { if (set_normalized_cda(&ch->ccw[4], skb->data)) {
/* /*
* idal allocation failed, try via copying to * idal allocation failed, try via copying to trans_skb.
* trans_skb. trans_skb usually has a pre-allocated * trans_skb usually has a pre-allocated idal.
* idal.
*/ */
if (ctcm_checkalloc_buffer(ch)) { if (ctcm_checkalloc_buffer(ch)) {
/* /*
* Remove our header. It gets added * Remove our header.
* again on retransmit. * It gets added again on retransmit.
*/ */
atomic_dec(&skb->users); goto nomem_exit;
dev_kfree_skb_any(skb);
printk(KERN_WARNING "ctcm: %s()OUT OF MEMORY:"
" Data Lost \n", __FUNCTION__);
fsm_event(priv->mpcg->fsm, MPCG_EVENT_INOP, dev);
goto done;
} }
skb_reset_tail_pointer(ch->trans_skb); skb_reset_tail_pointer(ch->trans_skb);
...@@ -829,14 +803,11 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb) ...@@ -829,14 +803,11 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb)
atomic_dec(&skb->users); atomic_dec(&skb->users);
dev_kfree_skb_irq(skb); dev_kfree_skb_irq(skb);
ccw_idx = 0; ccw_idx = 0;
if (do_debug_data) { CTCM_PR_DBGDATA("%s(%s): trans_skb len: %04x\n"
ctcm_pr_debug("ctcm: %s() TRANS skb len: %d \n", "up to 32 bytes sent to vtam:\n",
__FUNCTION__, ch->trans_skb->len); __func__, dev->name, ch->trans_skb->len);
ctcm_pr_debug("ctcm: %s up to 32 bytes of data" CTCM_D3_DUMP((char *)ch->trans_skb->data,
" sent to vtam\n", __FUNCTION__); min_t(int, 32, ch->trans_skb->len));
ctcmpc_dump32((char *)ch->trans_skb->data,
ch->trans_skb->len);
}
} else { } else {
skb_queue_tail(&ch->io_queue, skb); skb_queue_tail(&ch->io_queue, skb);
ccw_idx = 3; ccw_idx = 3;
...@@ -865,13 +836,21 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb) ...@@ -865,13 +836,21 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb)
priv->stats.tx_packets++; priv->stats.tx_packets++;
priv->stats.tx_bytes += skb->len - TH_HEADER_LENGTH; priv->stats.tx_bytes += skb->len - TH_HEADER_LENGTH;
} }
if (ch->th_seq_num > 0xf0000000) /* Chose 4Billion at random. */ if (ch->th_seq_num > 0xf0000000) /* Chose at random. */
ctcmpc_send_sweep_req(ch); ctcmpc_send_sweep_req(ch);
goto done;
nomem_exit:
CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_CRIT,
"%s(%s): MEMORY allocation ERROR\n",
CTCM_FUNTAIL, ch->id);
rc = -ENOMEM;
atomic_dec(&skb->users);
dev_kfree_skb_any(skb);
fsm_event(priv->mpcg->fsm, MPCG_EVENT_INOP, dev);
done: done:
if (do_debug) CTCM_PR_DEBUG("Exit %s(%s)\n", __func__, dev->name);
ctcm_pr_debug("ctcm exit: %s %s()\n", dev->name, __FUNCTION__); return rc;
return 0;
} }
/** /**
...@@ -888,20 +867,19 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb) ...@@ -888,20 +867,19 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb)
/* first merge version - leaving both functions separated */ /* first merge version - leaving both functions separated */
static int ctcm_tx(struct sk_buff *skb, struct net_device *dev) static int ctcm_tx(struct sk_buff *skb, struct net_device *dev)
{ {
int rc = 0; struct ctcm_priv *priv = dev->priv;
struct ctcm_priv *priv;
CTCM_DBF_TEXT(TRACE, 5, __FUNCTION__);
priv = dev->priv;
if (skb == NULL) { if (skb == NULL) {
ctcm_pr_warn("%s: NULL sk_buff passed\n", dev->name); CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR,
"%s(%s): NULL sk_buff passed",
CTCM_FUNTAIL, dev->name);
priv->stats.tx_dropped++; priv->stats.tx_dropped++;
return 0; return 0;
} }
if (skb_headroom(skb) < (LL_HEADER_LENGTH + 2)) { if (skb_headroom(skb) < (LL_HEADER_LENGTH + 2)) {
ctcm_pr_warn("%s: Got sk_buff with head room < %ld bytes\n", CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR,
dev->name, LL_HEADER_LENGTH + 2); "%s(%s): Got sk_buff with head room < %ld bytes",
CTCM_FUNTAIL, dev->name, LL_HEADER_LENGTH + 2);
dev_kfree_skb(skb); dev_kfree_skb(skb);
priv->stats.tx_dropped++; priv->stats.tx_dropped++;
return 0; return 0;
...@@ -925,51 +903,43 @@ static int ctcm_tx(struct sk_buff *skb, struct net_device *dev) ...@@ -925,51 +903,43 @@ static int ctcm_tx(struct sk_buff *skb, struct net_device *dev)
dev->trans_start = jiffies; dev->trans_start = jiffies;
if (ctcm_transmit_skb(priv->channel[WRITE], skb) != 0) if (ctcm_transmit_skb(priv->channel[WRITE], skb) != 0)
rc = 1; return 1;
return rc; return 0;
} }
/* unmerged MPC variant of ctcm_tx */ /* unmerged MPC variant of ctcm_tx */
static int ctcmpc_tx(struct sk_buff *skb, struct net_device *dev) static int ctcmpc_tx(struct sk_buff *skb, struct net_device *dev)
{ {
int len = 0; int len = 0;
struct ctcm_priv *priv = NULL; struct ctcm_priv *priv = dev->priv;
struct mpc_group *grp = NULL; struct mpc_group *grp = priv->mpcg;
struct sk_buff *newskb = NULL; struct sk_buff *newskb = NULL;
if (do_debug)
ctcm_pr_debug("ctcmpc enter: %s(): skb:%0lx\n",
__FUNCTION__, (unsigned long)skb);
CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_DEBUG,
"ctcmpc enter: %s(): skb:%0lx\n",
__FUNCTION__, (unsigned long)skb);
priv = dev->priv;
grp = priv->mpcg;
/* /*
* Some sanity checks ... * Some sanity checks ...
*/ */
if (skb == NULL) { if (skb == NULL) {
ctcm_pr_warn("ctcmpc: %s: NULL sk_buff passed\n", dev->name); CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"%s(%s): NULL sk_buff passed",
CTCM_FUNTAIL, dev->name);
priv->stats.tx_dropped++; priv->stats.tx_dropped++;
goto done; goto done;
} }
if (skb_headroom(skb) < (TH_HEADER_LENGTH + PDU_HEADER_LENGTH)) { if (skb_headroom(skb) < (TH_HEADER_LENGTH + PDU_HEADER_LENGTH)) {
CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_WARN, CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_ERROR,
"%s: Got sk_buff with head room < %ld bytes\n", "%s(%s): Got sk_buff with head room < %ld bytes",
dev->name, TH_HEADER_LENGTH + PDU_HEADER_LENGTH); CTCM_FUNTAIL, dev->name,
TH_HEADER_LENGTH + PDU_HEADER_LENGTH);
if (do_debug_data) CTCM_D3_DUMP((char *)skb->data, min_t(int, 32, skb->len));
ctcmpc_dump32((char *)skb->data, skb->len);
len = skb->len + TH_HEADER_LENGTH + PDU_HEADER_LENGTH; len = skb->len + TH_HEADER_LENGTH + PDU_HEADER_LENGTH;
newskb = __dev_alloc_skb(len, gfp_type() | GFP_DMA); newskb = __dev_alloc_skb(len, gfp_type() | GFP_DMA);
if (!newskb) { if (!newskb) {
printk(KERN_WARNING "ctcmpc: %s() OUT OF MEMORY-" CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_ERROR,
"Data Lost\n", "%s: %s: __dev_alloc_skb failed",
__FUNCTION__); __func__, dev->name);
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
priv->stats.tx_dropped++; priv->stats.tx_dropped++;
...@@ -993,9 +963,9 @@ static int ctcmpc_tx(struct sk_buff *skb, struct net_device *dev) ...@@ -993,9 +963,9 @@ static int ctcmpc_tx(struct sk_buff *skb, struct net_device *dev)
if ((fsm_getstate(priv->fsm) != DEV_STATE_RUNNING) || if ((fsm_getstate(priv->fsm) != DEV_STATE_RUNNING) ||
(fsm_getstate(grp->fsm) < MPCG_STATE_XID2INITW)) { (fsm_getstate(grp->fsm) < MPCG_STATE_XID2INITW)) {
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
printk(KERN_INFO "ctcmpc: %s() DATA RCVD - MPC GROUP " CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"NOT ACTIVE - DROPPED\n", "%s(%s): inactive MPCGROUP - dropped",
__FUNCTION__); CTCM_FUNTAIL, dev->name);
priv->stats.tx_dropped++; priv->stats.tx_dropped++;
priv->stats.tx_errors++; priv->stats.tx_errors++;
priv->stats.tx_carrier_errors++; priv->stats.tx_carrier_errors++;
...@@ -1003,8 +973,9 @@ static int ctcmpc_tx(struct sk_buff *skb, struct net_device *dev) ...@@ -1003,8 +973,9 @@ static int ctcmpc_tx(struct sk_buff *skb, struct net_device *dev)
} }
if (ctcm_test_and_set_busy(dev)) { if (ctcm_test_and_set_busy(dev)) {
printk(KERN_WARNING "%s:DEVICE ERR - UNRECOVERABLE DATA LOSS\n", CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
__FUNCTION__); "%s(%s): device busy - dropped",
CTCM_FUNTAIL, dev->name);
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
priv->stats.tx_dropped++; priv->stats.tx_dropped++;
priv->stats.tx_errors++; priv->stats.tx_errors++;
...@@ -1015,12 +986,9 @@ static int ctcmpc_tx(struct sk_buff *skb, struct net_device *dev) ...@@ -1015,12 +986,9 @@ static int ctcmpc_tx(struct sk_buff *skb, struct net_device *dev)
dev->trans_start = jiffies; dev->trans_start = jiffies;
if (ctcmpc_transmit_skb(priv->channel[WRITE], skb) != 0) { if (ctcmpc_transmit_skb(priv->channel[WRITE], skb) != 0) {
printk(KERN_WARNING "ctcmpc: %s() DEVICE ERROR" CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
": Data Lost \n", "%s(%s): device error - dropped",
__FUNCTION__); CTCM_FUNTAIL, dev->name);
printk(KERN_WARNING "ctcmpc: %s() DEVICE ERROR"
" - UNRECOVERABLE DATA LOSS\n",
__FUNCTION__);
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
priv->stats.tx_dropped++; priv->stats.tx_dropped++;
priv->stats.tx_errors++; priv->stats.tx_errors++;
...@@ -1054,8 +1022,6 @@ static int ctcm_change_mtu(struct net_device *dev, int new_mtu) ...@@ -1054,8 +1022,6 @@ static int ctcm_change_mtu(struct net_device *dev, int new_mtu)
struct ctcm_priv *priv; struct ctcm_priv *priv;
int max_bufsize; int max_bufsize;
CTCM_DBF_TEXT(SETUP, CTC_DBF_INFO, __FUNCTION__);
if (new_mtu < 576 || new_mtu > 65527) if (new_mtu < 576 || new_mtu > 65527)
return -EINVAL; return -EINVAL;
...@@ -1087,30 +1053,13 @@ static struct net_device_stats *ctcm_stats(struct net_device *dev) ...@@ -1087,30 +1053,13 @@ static struct net_device_stats *ctcm_stats(struct net_device *dev)
return &((struct ctcm_priv *)dev->priv)->stats; return &((struct ctcm_priv *)dev->priv)->stats;
} }
static void ctcm_netdev_unregister(struct net_device *dev)
{
CTCM_DBF_TEXT(SETUP, CTC_DBF_INFO, __FUNCTION__);
if (!dev)
return;
unregister_netdev(dev);
}
static int ctcm_netdev_register(struct net_device *dev)
{
CTCM_DBF_TEXT(SETUP, CTC_DBF_INFO, __FUNCTION__);
return register_netdev(dev);
}
static void ctcm_free_netdevice(struct net_device *dev) static void ctcm_free_netdevice(struct net_device *dev)
{ {
struct ctcm_priv *priv; struct ctcm_priv *priv;
struct mpc_group *grp; struct mpc_group *grp;
CTCM_DBF_TEXT(SETUP, CTC_DBF_INFO, __FUNCTION__); CTCM_DBF_TEXT_(SETUP, CTC_DBF_INFO,
"%s(%s)", CTCM_FUNTAIL, dev->name);
if (!dev)
return;
priv = dev->priv; priv = dev->priv;
if (priv) { if (priv) {
grp = priv->mpcg; grp = priv->mpcg;
...@@ -1171,7 +1120,9 @@ static struct net_device *ctcm_init_netdevice(struct ctcm_priv *priv) ...@@ -1171,7 +1120,9 @@ static struct net_device *ctcm_init_netdevice(struct ctcm_priv *priv)
dev = alloc_netdev(0, CTC_DEVICE_GENE, ctcm_dev_setup); dev = alloc_netdev(0, CTC_DEVICE_GENE, ctcm_dev_setup);
if (!dev) { if (!dev) {
ctcm_pr_err("%s: Out of memory\n", __FUNCTION__); CTCM_DBF_TEXT_(ERROR, CTC_DBF_CRIT,
"%s: MEMORY allocation ERROR",
CTCM_FUNTAIL);
return NULL; return NULL;
} }
dev->priv = priv; dev->priv = priv;
...@@ -1209,6 +1160,7 @@ static struct net_device *ctcm_init_netdevice(struct ctcm_priv *priv) ...@@ -1209,6 +1160,7 @@ static struct net_device *ctcm_init_netdevice(struct ctcm_priv *priv)
} }
CTCMY_DBF_DEV(SETUP, dev, "finished"); CTCMY_DBF_DEV(SETUP, dev, "finished");
return dev; return dev;
} }
...@@ -1226,18 +1178,24 @@ static void ctcm_irq_handler(struct ccw_device *cdev, ...@@ -1226,18 +1178,24 @@ static void ctcm_irq_handler(struct ccw_device *cdev,
struct net_device *dev; struct net_device *dev;
struct ctcm_priv *priv; struct ctcm_priv *priv;
struct ccwgroup_device *cgdev; struct ccwgroup_device *cgdev;
int cstat;
int dstat;
CTCM_DBF_TEXT_(TRACE, CTC_DBF_DEBUG,
"Enter %s(%s)", CTCM_FUNTAIL, &cdev->dev.bus_id);
CTCM_DBF_TEXT(TRACE, CTC_DBF_DEBUG, __FUNCTION__);
if (ctcm_check_irb_error(cdev, irb)) if (ctcm_check_irb_error(cdev, irb))
return; return;
cgdev = dev_get_drvdata(&cdev->dev); cgdev = dev_get_drvdata(&cdev->dev);
cstat = irb->scsw.cmd.cstat;
dstat = irb->scsw.cmd.dstat;
/* Check for unsolicited interrupts. */ /* Check for unsolicited interrupts. */
if (cgdev == NULL) { if (cgdev == NULL) {
ctcm_pr_warn("ctcm: Got unsolicited irq: %s c-%02x d-%02x\n", ctcm_pr_warn("ctcm: Got unsolicited irq: c-%02x d-%02x\n",
cdev->dev.bus_id, irb->scsw.cmd.cstat, cstat, dstat);
irb->scsw.cmd.dstat);
return; return;
} }
...@@ -1254,26 +1212,22 @@ static void ctcm_irq_handler(struct ccw_device *cdev, ...@@ -1254,26 +1212,22 @@ static void ctcm_irq_handler(struct ccw_device *cdev,
return; return;
} }
dev = (struct net_device *)(ch->netdev); dev = ch->netdev;
if (dev == NULL) { if (dev == NULL) {
ctcm_pr_crit("ctcm: %s dev=NULL bus_id=%s, ch=0x%p\n", ctcm_pr_crit("ctcm: %s dev=NULL bus_id=%s, ch=0x%p\n",
__FUNCTION__, cdev->dev.bus_id, ch); __func__, cdev->dev.bus_id, ch);
return; return;
} }
if (do_debug) CTCM_DBF_TEXT_(TRACE, CTC_DBF_DEBUG,
ctcm_pr_debug("%s: interrupt for device: %s " "%s(%s): int. for %s: cstat=%02x dstat=%02x",
"received c-%02x d-%02x\n", CTCM_FUNTAIL, dev->name, ch->id, cstat, dstat);
dev->name,
ch->id,
irb->scsw.cmd.cstat,
irb->scsw.cmd.dstat);
/* Copy interruption response block. */ /* Copy interruption response block. */
memcpy(ch->irb, irb, sizeof(struct irb)); memcpy(ch->irb, irb, sizeof(struct irb));
/* Check for good subchannel return code, otherwise error message */
if (irb->scsw.cmd.cstat) { if (irb->scsw.cmd.cstat) {
/* Check for good subchannel return code, otherwise error message */
fsm_event(ch->fsm, CTC_EVENT_SC_UNKNOWN, ch); fsm_event(ch->fsm, CTC_EVENT_SC_UNKNOWN, ch);
ctcm_pr_warn("%s: subchannel check for dev: %s - %02x %02x\n", ctcm_pr_warn("%s: subchannel check for dev: %s - %02x %02x\n",
dev->name, ch->id, irb->scsw.cmd.cstat, dev->name, ch->id, irb->scsw.cmd.cstat,
...@@ -1283,6 +1237,11 @@ static void ctcm_irq_handler(struct ccw_device *cdev, ...@@ -1283,6 +1237,11 @@ static void ctcm_irq_handler(struct ccw_device *cdev,
/* Check the reason-code of a unit check */ /* Check the reason-code of a unit check */
if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) { if (irb->scsw.cmd.dstat & DEV_STAT_UNIT_CHECK) {
if ((irb->ecw[0] & ch->sense_rc) == 0)
/* print it only once */
CTCM_DBF_TEXT_(TRACE, CTC_DBF_INFO,
"%s(%s): sense=%02x, ds=%02x",
CTCM_FUNTAIL, ch->id, irb->ecw[0], dstat);
ccw_unit_check(ch, irb->ecw[0]); ccw_unit_check(ch, irb->ecw[0]);
return; return;
} }
...@@ -1320,14 +1279,18 @@ static int ctcm_probe_device(struct ccwgroup_device *cgdev) ...@@ -1320,14 +1279,18 @@ static int ctcm_probe_device(struct ccwgroup_device *cgdev)
struct ctcm_priv *priv; struct ctcm_priv *priv;
int rc; int rc;
CTCM_DBF_TEXT_(SETUP, CTC_DBF_INFO, "%s %p", __FUNCTION__, cgdev); CTCM_DBF_TEXT_(SETUP, CTC_DBF_INFO,
"%s %p",
__func__, cgdev);
if (!get_device(&cgdev->dev)) if (!get_device(&cgdev->dev))
return -ENODEV; return -ENODEV;
priv = kzalloc(sizeof(struct ctcm_priv), GFP_KERNEL); priv = kzalloc(sizeof(struct ctcm_priv), GFP_KERNEL);
if (!priv) { if (!priv) {
ctcm_pr_err("%s: Out of memory\n", __FUNCTION__); CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR,
"%s: memory allocation failure",
CTCM_FUNTAIL);
put_device(&cgdev->dev); put_device(&cgdev->dev);
return -ENOMEM; return -ENOMEM;
} }
...@@ -1364,10 +1327,13 @@ static int add_channel(struct ccw_device *cdev, enum channel_types type, ...@@ -1364,10 +1327,13 @@ static int add_channel(struct ccw_device *cdev, enum channel_types type,
int ccw_num; int ccw_num;
int rc = 0; int rc = 0;
CTCM_DBF_TEXT(TRACE, 2, __FUNCTION__); CTCM_DBF_TEXT_(SETUP, CTC_DBF_INFO,
"%s(%s), type %d, proto %d",
__func__, cdev->dev.bus_id, type, priv->protocol);
ch = kzalloc(sizeof(struct channel), GFP_KERNEL); ch = kzalloc(sizeof(struct channel), GFP_KERNEL);
if (ch == NULL) if (ch == NULL)
goto nomem_return; return -ENOMEM;
ch->protocol = priv->protocol; ch->protocol = priv->protocol;
if (IS_MPC(priv)) { if (IS_MPC(priv)) {
...@@ -1478,7 +1444,7 @@ static int add_channel(struct ccw_device *cdev, enum channel_types type, ...@@ -1478,7 +1444,7 @@ static int add_channel(struct ccw_device *cdev, enum channel_types type,
if (*c && (!strncmp((*c)->id, ch->id, CTCM_ID_SIZE))) { if (*c && (!strncmp((*c)->id, ch->id, CTCM_ID_SIZE))) {
CTCM_DBF_TEXT_(SETUP, CTC_DBF_INFO, CTCM_DBF_TEXT_(SETUP, CTC_DBF_INFO,
"%s (%s) already in list, using old entry", "%s (%s) already in list, using old entry",
__FUNCTION__, (*c)->id); __func__, (*c)->id);
goto free_return; goto free_return;
} }
...@@ -1498,11 +1464,10 @@ static int add_channel(struct ccw_device *cdev, enum channel_types type, ...@@ -1498,11 +1464,10 @@ static int add_channel(struct ccw_device *cdev, enum channel_types type,
return 0; return 0;
nomem_return: nomem_return:
ctcm_pr_warn("ctcm: Out of memory in %s\n", __FUNCTION__);
rc = -ENOMEM; rc = -ENOMEM;
free_return: /* note that all channel pointers are 0 or valid */ free_return: /* note that all channel pointers are 0 or valid */
kfree(ch->ccw); /* TODO: check that again */ kfree(ch->ccw);
kfree(ch->discontact_th); kfree(ch->discontact_th);
kfree_fsm(ch->fsm); kfree_fsm(ch->fsm);
kfree(ch->irb); kfree(ch->irb);
...@@ -1540,48 +1505,48 @@ static int ctcm_new_device(struct ccwgroup_device *cgdev) ...@@ -1540,48 +1505,48 @@ static int ctcm_new_device(struct ccwgroup_device *cgdev)
enum channel_types type; enum channel_types type;
struct ctcm_priv *priv; struct ctcm_priv *priv;
struct net_device *dev; struct net_device *dev;
struct ccw_device *cdev0;
struct ccw_device *cdev1;
int ret; int ret;
CTCM_DBF_TEXT(SETUP, CTC_DBF_INFO, __FUNCTION__);
priv = dev_get_drvdata(&cgdev->dev); priv = dev_get_drvdata(&cgdev->dev);
if (!priv) if (!priv)
return -ENODEV; return -ENODEV;
type = get_channel_type(&cgdev->cdev[0]->id); cdev0 = cgdev->cdev[0];
cdev1 = cgdev->cdev[1];
type = get_channel_type(&cdev0->id);
snprintf(read_id, CTCM_ID_SIZE, "ch-%s", cgdev->cdev[0]->dev.bus_id); snprintf(read_id, CTCM_ID_SIZE, "ch-%s", cdev0->dev.bus_id);
snprintf(write_id, CTCM_ID_SIZE, "ch-%s", cgdev->cdev[1]->dev.bus_id); snprintf(write_id, CTCM_ID_SIZE, "ch-%s", cdev1->dev.bus_id);
ret = add_channel(cgdev->cdev[0], type, priv); ret = add_channel(cdev0, type, priv);
if (ret) if (ret)
return ret; return ret;
ret = add_channel(cgdev->cdev[1], type, priv); ret = add_channel(cdev1, type, priv);
if (ret) if (ret)
return ret; return ret;
ret = ccw_device_set_online(cgdev->cdev[0]); ret = ccw_device_set_online(cdev0);
if (ret != 0) { if (ret != 0) {
CTCM_DBF_TEXT(SETUP, CTC_DBF_WARN, /* may be ok to fail now - can be done later */
"ccw_device_set_online (cdev[0]) failed "); CTCM_DBF_TEXT_(TRACE, CTC_DBF_NOTICE,
ctcm_pr_warn("ccw_device_set_online (cdev[0]) failed " "%s(%s) set_online rc=%d",
"with ret = %d\n", ret); CTCM_FUNTAIL, read_id, ret);
} }
ret = ccw_device_set_online(cgdev->cdev[1]); ret = ccw_device_set_online(cdev1);
if (ret != 0) { if (ret != 0) {
CTCM_DBF_TEXT(SETUP, CTC_DBF_WARN, /* may be ok to fail now - can be done later */
"ccw_device_set_online (cdev[1]) failed "); CTCM_DBF_TEXT_(TRACE, CTC_DBF_NOTICE,
ctcm_pr_warn("ccw_device_set_online (cdev[1]) failed " "%s(%s) set_online rc=%d",
"with ret = %d\n", ret); CTCM_FUNTAIL, write_id, ret);
} }
dev = ctcm_init_netdevice(priv); dev = ctcm_init_netdevice(priv);
if (dev == NULL)
if (dev == NULL) {
ctcm_pr_warn("ctcm_init_netdevice failed\n");
goto out; goto out;
}
for (direction = READ; direction <= WRITE; direction++) { for (direction = READ; direction <= WRITE; direction++) {
priv->channel[direction] = priv->channel[direction] =
...@@ -1590,8 +1555,7 @@ static int ctcm_new_device(struct ccwgroup_device *cgdev) ...@@ -1590,8 +1555,7 @@ static int ctcm_new_device(struct ccwgroup_device *cgdev)
if (priv->channel[direction] == NULL) { if (priv->channel[direction] == NULL) {
if (direction == WRITE) if (direction == WRITE)
channel_free(priv->channel[READ]); channel_free(priv->channel[READ]);
ctcm_free_netdevice(dev); goto out_dev;
goto out;
} }
priv->channel[direction]->netdev = dev; priv->channel[direction]->netdev = dev;
priv->channel[direction]->protocol = priv->protocol; priv->channel[direction]->protocol = priv->protocol;
...@@ -1600,26 +1564,24 @@ static int ctcm_new_device(struct ccwgroup_device *cgdev) ...@@ -1600,26 +1564,24 @@ static int ctcm_new_device(struct ccwgroup_device *cgdev)
/* sysfs magic */ /* sysfs magic */
SET_NETDEV_DEV(dev, &cgdev->dev); SET_NETDEV_DEV(dev, &cgdev->dev);
if (ctcm_netdev_register(dev) != 0) { if (register_netdev(dev))
ctcm_free_netdevice(dev); goto out_dev;
goto out;
}
if (ctcm_add_attributes(&cgdev->dev)) { if (ctcm_add_attributes(&cgdev->dev)) {
ctcm_netdev_unregister(dev); unregister_netdev(dev);
/* dev->priv = NULL; why that ???? */ goto out_dev;
ctcm_free_netdevice(dev);
goto out;
} }
strlcpy(priv->fsm->name, dev->name, sizeof(priv->fsm->name)); strlcpy(priv->fsm->name, dev->name, sizeof(priv->fsm->name));
CTCM_DBF_TEXT_(SETUP, CTC_DBF_INFO, CTCM_DBF_TEXT_(SETUP, CTC_DBF_INFO,
"setup(%s) ok : r/w = %s / %s, proto : %d", "setup(%s) OK : r/w = %s/%s, protocol : %d", dev->name,
dev->name, priv->channel[READ]->id, priv->channel[READ]->id,
priv->channel[WRITE]->id, priv->protocol); priv->channel[WRITE]->id, priv->protocol);
return 0; return 0;
out_dev:
ctcm_free_netdevice(dev);
out: out:
ccw_device_set_offline(cgdev->cdev[1]); ccw_device_set_offline(cgdev->cdev[1]);
ccw_device_set_offline(cgdev->cdev[0]); ccw_device_set_offline(cgdev->cdev[0]);
...@@ -1658,8 +1620,7 @@ static int ctcm_shutdown_device(struct ccwgroup_device *cgdev) ...@@ -1658,8 +1620,7 @@ static int ctcm_shutdown_device(struct ccwgroup_device *cgdev)
channel_free(priv->channel[WRITE]); channel_free(priv->channel[WRITE]);
if (dev) { if (dev) {
ctcm_netdev_unregister(dev); unregister_netdev(dev);
/* dev->priv = NULL; why that ??? */
ctcm_free_netdevice(dev); ctcm_free_netdevice(dev);
} }
...@@ -1682,13 +1643,16 @@ static int ctcm_shutdown_device(struct ccwgroup_device *cgdev) ...@@ -1682,13 +1643,16 @@ static int ctcm_shutdown_device(struct ccwgroup_device *cgdev)
static void ctcm_remove_device(struct ccwgroup_device *cgdev) static void ctcm_remove_device(struct ccwgroup_device *cgdev)
{ {
struct ctcm_priv *priv; struct ctcm_priv *priv = dev_get_drvdata(&cgdev->dev);
CTCM_DBF_TEXT(SETUP, CTC_DBF_ERROR, __FUNCTION__); BUG_ON(priv == NULL);
CTCM_DBF_TEXT_(SETUP, CTC_DBF_INFO,
"removing device %s, r/w = %s/%s, proto : %d",
priv->channel[READ]->netdev->name,
priv->channel[READ]->id, priv->channel[WRITE]->id,
priv->protocol);
priv = dev_get_drvdata(&cgdev->dev);
if (!priv)
return;
if (cgdev->state == CCWGROUP_ONLINE) if (cgdev->state == CCWGROUP_ONLINE)
ctcm_shutdown_device(cgdev); ctcm_shutdown_device(cgdev);
ctcm_remove_files(&cgdev->dev); ctcm_remove_files(&cgdev->dev);
...@@ -1748,8 +1712,6 @@ static int __init ctcm_init(void) ...@@ -1748,8 +1712,6 @@ static int __init ctcm_init(void)
ret = ctcm_register_dbf_views(); ret = ctcm_register_dbf_views();
if (ret) { if (ret) {
ctcm_pr_crit("ctcm_init failed with ctcm_register_dbf_views "
"rc = %d\n", ret);
return ret; return ret;
} }
ret = register_cu3088_discipline(&ctcm_group_driver); ret = register_cu3088_discipline(&ctcm_group_driver);
......
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
#define CTC_DRIVER_NAME "ctcm" #define CTC_DRIVER_NAME "ctcm"
#define CTC_DEVICE_NAME "ctc" #define CTC_DEVICE_NAME "ctc"
#define CTC_DEVICE_GENE "ctc%d"
#define MPC_DEVICE_NAME "mpc" #define MPC_DEVICE_NAME "mpc"
#define MPC_DEVICE_GENE "mpc%d" #define CTC_DEVICE_GENE CTC_DEVICE_NAME "%d"
#define MPC_DEVICE_GENE MPC_DEVICE_NAME "%d"
#define CHANNEL_FLAGS_READ 0 #define CHANNEL_FLAGS_READ 0
#define CHANNEL_FLAGS_WRITE 1 #define CHANNEL_FLAGS_WRITE 1
...@@ -48,6 +48,30 @@ ...@@ -48,6 +48,30 @@
#define ctcm_pr_err(fmt, arg...) printk(KERN_ERR fmt, ##arg) #define ctcm_pr_err(fmt, arg...) printk(KERN_ERR fmt, ##arg)
#define ctcm_pr_crit(fmt, arg...) printk(KERN_CRIT fmt, ##arg) #define ctcm_pr_crit(fmt, arg...) printk(KERN_CRIT fmt, ##arg)
#define CTCM_PR_DEBUG(fmt, arg...) \
do { \
if (do_debug) \
printk(KERN_DEBUG fmt, ##arg); \
} while (0)
#define CTCM_PR_DBGDATA(fmt, arg...) \
do { \
if (do_debug_data) \
printk(KERN_DEBUG fmt, ##arg); \
} while (0)
#define CTCM_D3_DUMP(buf, len) \
do { \
if (do_debug_data) \
ctcmpc_dumpit(buf, len); \
} while (0)
#define CTCM_CCW_DUMP(buf, len) \
do { \
if (do_debug_ccw) \
ctcmpc_dumpit(buf, len); \
} while (0)
/* /*
* CCW commands, used in this driver. * CCW commands, used in this driver.
*/ */
...@@ -161,8 +185,9 @@ struct channel { ...@@ -161,8 +185,9 @@ struct channel {
fsm_instance *fsm; /* finite state machine of this channel */ fsm_instance *fsm; /* finite state machine of this channel */
struct net_device *netdev; /* corresponding net_device */ struct net_device *netdev; /* corresponding net_device */
struct ctcm_profile prof; struct ctcm_profile prof;
unsigned char *trans_skb_data; __u8 *trans_skb_data;
__u16 logflags; __u16 logflags;
__u8 sense_rc; /* last unit check sense code report control */
}; };
struct ctcm_priv { struct ctcm_priv {
......
...@@ -149,7 +149,7 @@ void ctcmpc_dumpit(char *buf, int len) ...@@ -149,7 +149,7 @@ void ctcmpc_dumpit(char *buf, int len)
for (ct = 0; ct < len; ct++, ptr++, rptr++) { for (ct = 0; ct < len; ct++, ptr++, rptr++) {
if (sw == 0) { if (sw == 0) {
#if (UTS_MACHINE == s390x) #if (UTS_MACHINE == s390x)
sprintf(addr, "%16.16lx", (unsigned long)rptr); sprintf(addr, "%16.16lx", (__u64)rptr);
#else #else
sprintf(addr, "%8.8X", (__u32)rptr); sprintf(addr, "%8.8X", (__u32)rptr);
#endif #endif
...@@ -164,7 +164,7 @@ void ctcmpc_dumpit(char *buf, int len) ...@@ -164,7 +164,7 @@ void ctcmpc_dumpit(char *buf, int len)
strcat(bhex, " "); strcat(bhex, " ");
#if (UTS_MACHINE == s390x) #if (UTS_MACHINE == s390x)
sprintf(tbuf, "%2.2lX", (unsigned long)*ptr); sprintf(tbuf, "%2.2lX", (__u64)*ptr);
#else #else
sprintf(tbuf, "%2.2X", (__u32)*ptr); sprintf(tbuf, "%2.2X", (__u32)*ptr);
#endif #endif
...@@ -179,15 +179,16 @@ void ctcmpc_dumpit(char *buf, int len) ...@@ -179,15 +179,16 @@ void ctcmpc_dumpit(char *buf, int len)
basc[sw+1] = '\0'; basc[sw+1] = '\0';
sw++; sw++;
rm--; rm--;
if (sw == 16) { if (sw != 16)
continue;
if ((strcmp(duphex, bhex)) != 0) { if ((strcmp(duphex, bhex)) != 0) {
if (dup != 0) { if (dup != 0) {
sprintf(tdup, "Duplicate as above " sprintf(tdup,
"to %s", addr); "Duplicate as above to %s", addr);
printk(KERN_INFO " " ctcm_pr_debug(" --- %s ---\n",
" --- %s ---\n", tdup); tdup);
} }
printk(KERN_INFO " %s (+%s) : %s [%s]\n", ctcm_pr_debug(" %s (+%s) : %s [%s]\n",
addr, boff, bhex, basc); addr, boff, bhex, basc);
dup = 0; dup = 0;
strcpy(duphex, bhex); strcpy(duphex, bhex);
...@@ -196,7 +197,6 @@ void ctcmpc_dumpit(char *buf, int len) ...@@ -196,7 +197,6 @@ void ctcmpc_dumpit(char *buf, int len)
sw = 0; sw = 0;
rm = 16; rm = 16;
}
} /* endfor */ } /* endfor */
if (sw != 0) { if (sw != 0) {
...@@ -210,19 +210,17 @@ void ctcmpc_dumpit(char *buf, int len) ...@@ -210,19 +210,17 @@ void ctcmpc_dumpit(char *buf, int len)
} }
if (dup != 0) { if (dup != 0) {
sprintf(tdup, "Duplicate as above to %s", addr); sprintf(tdup, "Duplicate as above to %s", addr);
printk(KERN_INFO " " ctcm_pr_debug(" --- %s ---\n", tdup);
" --- %s ---\n", tdup);
} }
printk(KERN_INFO " %s (+%s) : %s [%s]\n", ctcm_pr_debug(" %s (+%s) : %s [%s]\n",
addr, boff, bhex, basc); addr, boff, bhex, basc);
} else { } else {
if (dup >= 1) { if (dup >= 1) {
sprintf(tdup, "Duplicate as above to %s", addr); sprintf(tdup, "Duplicate as above to %s", addr);
printk(KERN_INFO " " ctcm_pr_debug(" --- %s ---\n", tdup);
" --- %s ---\n", tdup);
} }
if (dup != 0) { if (dup != 0) {
printk(KERN_INFO " %s (+%s) : %s [%s]\n", ctcm_pr_debug(" %s (+%s) : %s [%s]\n",
addr, boff, bhex, basc); addr, boff, bhex, basc);
} }
} }
...@@ -241,7 +239,7 @@ void ctcmpc_dumpit(char *buf, int len) ...@@ -241,7 +239,7 @@ void ctcmpc_dumpit(char *buf, int len)
*/ */
void ctcmpc_dump_skb(struct sk_buff *skb, int offset) void ctcmpc_dump_skb(struct sk_buff *skb, int offset)
{ {
unsigned char *p = skb->data; __u8 *p = skb->data;
struct th_header *header; struct th_header *header;
struct pdu *pheader; struct pdu *pheader;
int bl = skb->len; int bl = skb->len;
...@@ -253,8 +251,8 @@ void ctcmpc_dump_skb(struct sk_buff *skb, int offset) ...@@ -253,8 +251,8 @@ void ctcmpc_dump_skb(struct sk_buff *skb, int offset)
p += offset; p += offset;
header = (struct th_header *)p; header = (struct th_header *)p;
printk(KERN_INFO "dump:\n"); ctcm_pr_debug("dump:\n");
printk(KERN_INFO "skb len=%d \n", skb->len); ctcm_pr_debug("skb len=%d \n", skb->len);
if (skb->len > 2) { if (skb->len > 2) {
switch (header->th_ch_flag) { switch (header->th_ch_flag) {
case TH_HAS_PDU: case TH_HAS_PDU:
...@@ -273,32 +271,64 @@ void ctcmpc_dump_skb(struct sk_buff *skb, int offset) ...@@ -273,32 +271,64 @@ void ctcmpc_dump_skb(struct sk_buff *skb, int offset)
} }
pheader = (struct pdu *)p; pheader = (struct pdu *)p;
printk(KERN_INFO "pdu->offset: %d hex: %04x\n", ctcm_pr_debug("pdu->offset: %d hex: %04x\n",
pheader->pdu_offset, pheader->pdu_offset); pheader->pdu_offset, pheader->pdu_offset);
printk(KERN_INFO "pdu->flag : %02x\n", pheader->pdu_flag); ctcm_pr_debug("pdu->flag : %02x\n", pheader->pdu_flag);
printk(KERN_INFO "pdu->proto : %02x\n", pheader->pdu_proto); ctcm_pr_debug("pdu->proto : %02x\n", pheader->pdu_proto);
printk(KERN_INFO "pdu->seq : %02x\n", pheader->pdu_seq); ctcm_pr_debug("pdu->seq : %02x\n", pheader->pdu_seq);
goto dumpdata; goto dumpdata;
dumpth: dumpth:
printk(KERN_INFO "th->seg : %02x\n", header->th_seg); ctcm_pr_debug("th->seg : %02x\n", header->th_seg);
printk(KERN_INFO "th->ch : %02x\n", header->th_ch_flag); ctcm_pr_debug("th->ch : %02x\n", header->th_ch_flag);
printk(KERN_INFO "th->blk_flag: %02x\n", header->th_blk_flag); ctcm_pr_debug("th->blk_flag: %02x\n", header->th_blk_flag);
printk(KERN_INFO "th->type : %s\n", ctcm_pr_debug("th->type : %s\n",
(header->th_is_xid) ? "DATA" : "XID"); (header->th_is_xid) ? "DATA" : "XID");
printk(KERN_INFO "th->seqnum : %04x\n", header->th_seq_num); ctcm_pr_debug("th->seqnum : %04x\n", header->th_seq_num);
} }
dumpdata: dumpdata:
if (bl > 32) if (bl > 32)
bl = 32; bl = 32;
printk(KERN_INFO "data: "); ctcm_pr_debug("data: ");
for (i = 0; i < bl; i++) for (i = 0; i < bl; i++)
printk(KERN_INFO "%02x%s", *p++, (i % 16) ? " " : "\n<7>"); ctcm_pr_debug("%02x%s", *p++, (i % 16) ? " " : "\n");
printk(KERN_INFO "\n"); ctcm_pr_debug("\n");
} }
#endif #endif
static struct net_device *ctcmpc_get_dev(int port_num)
{
char device[20];
struct net_device *dev;
struct ctcm_priv *priv;
sprintf(device, "%s%i", MPC_DEVICE_NAME, port_num);
dev = __dev_get_by_name(&init_net, device);
if (dev == NULL) {
CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"%s: Device not found by name: %s",
CTCM_FUNTAIL, device);
return NULL;
}
priv = dev->priv;
if (priv == NULL) {
CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"%s(%s): dev->priv is NULL",
CTCM_FUNTAIL, device);
return NULL;
}
if (priv->mpcg == NULL) {
CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"%s(%s): priv->mpcg is NULL",
CTCM_FUNTAIL, device);
return NULL;
}
return dev;
}
/* /*
* ctc_mpc_alloc_channel * ctc_mpc_alloc_channel
* (exported interface) * (exported interface)
...@@ -308,34 +338,23 @@ void ctcmpc_dump_skb(struct sk_buff *skb, int offset) ...@@ -308,34 +338,23 @@ void ctcmpc_dump_skb(struct sk_buff *skb, int offset)
*/ */
int ctc_mpc_alloc_channel(int port_num, void (*callback)(int, int)) int ctc_mpc_alloc_channel(int port_num, void (*callback)(int, int))
{ {
char device[20];
struct net_device *dev; struct net_device *dev;
struct mpc_group *grp; struct mpc_group *grp;
struct ctcm_priv *priv; struct ctcm_priv *priv;
ctcm_pr_debug("ctcmpc enter: %s()\n", __FUNCTION__); dev = ctcmpc_get_dev(port_num);
if (dev == NULL)
sprintf(device, "%s%i", MPC_DEVICE_NAME, port_num);
dev = __dev_get_by_name(&init_net, device);
if (dev == NULL) {
printk(KERN_INFO "ctc_mpc_alloc_channel %s dev=NULL\n", device);
return 1; return 1;
}
priv = dev->priv; priv = dev->priv;
grp = priv->mpcg; grp = priv->mpcg;
if (!grp)
return 1;
grp->allochanfunc = callback; grp->allochanfunc = callback;
grp->port_num = port_num; grp->port_num = port_num;
grp->port_persist = 1; grp->port_persist = 1;
ctcm_pr_debug("ctcmpc: %s called for device %s state=%s\n", CTCM_DBF_TEXT_(MPC_SETUP, CTC_DBF_INFO,
__FUNCTION__, "%s(%s): state=%s",
dev->name, CTCM_FUNTAIL, dev->name, fsm_getstate_str(grp->fsm));
fsm_getstate_str(grp->fsm));
switch (fsm_getstate(grp->fsm)) { switch (fsm_getstate(grp->fsm)) {
case MPCG_STATE_INOP: case MPCG_STATE_INOP:
...@@ -377,12 +396,8 @@ int ctc_mpc_alloc_channel(int port_num, void (*callback)(int, int)) ...@@ -377,12 +396,8 @@ int ctc_mpc_alloc_channel(int port_num, void (*callback)(int, int))
grp->allocchan_callback_retries = 0; grp->allocchan_callback_retries = 0;
} }
break; break;
default:
return 0;
} }
ctcm_pr_debug("ctcmpc exit: %s()\n", __FUNCTION__);
return 0; return 0;
} }
EXPORT_SYMBOL(ctc_mpc_alloc_channel); EXPORT_SYMBOL(ctc_mpc_alloc_channel);
...@@ -394,31 +409,22 @@ EXPORT_SYMBOL(ctc_mpc_alloc_channel); ...@@ -394,31 +409,22 @@ EXPORT_SYMBOL(ctc_mpc_alloc_channel);
void ctc_mpc_establish_connectivity(int port_num, void ctc_mpc_establish_connectivity(int port_num,
void (*callback)(int, int, int)) void (*callback)(int, int, int))
{ {
char device[20];
struct net_device *dev; struct net_device *dev;
struct mpc_group *grp; struct mpc_group *grp;
struct ctcm_priv *priv; struct ctcm_priv *priv;
struct channel *rch, *wch; struct channel *rch, *wch;
ctcm_pr_debug("ctcmpc enter: %s()\n", __FUNCTION__); dev = ctcmpc_get_dev(port_num);
if (dev == NULL)
sprintf(device, "%s%i", MPC_DEVICE_NAME, port_num);
dev = __dev_get_by_name(&init_net, device);
if (dev == NULL) {
printk(KERN_INFO "ctc_mpc_establish_connectivity "
"%s dev=NULL\n", device);
return; return;
}
priv = dev->priv; priv = dev->priv;
grp = priv->mpcg;
rch = priv->channel[READ]; rch = priv->channel[READ];
wch = priv->channel[WRITE]; wch = priv->channel[WRITE];
grp = priv->mpcg; CTCM_DBF_TEXT_(MPC_SETUP, CTC_DBF_INFO,
"%s(%s): state=%s",
ctcm_pr_debug("ctcmpc: %s() called for device %s state=%s\n", CTCM_FUNTAIL, dev->name, fsm_getstate_str(grp->fsm));
__FUNCTION__, dev->name,
fsm_getstate_str(grp->fsm));
grp->estconnfunc = callback; grp->estconnfunc = callback;
grp->port_num = port_num; grp->port_num = port_num;
...@@ -446,8 +452,10 @@ void ctc_mpc_establish_connectivity(int port_num, ...@@ -446,8 +452,10 @@ void ctc_mpc_establish_connectivity(int port_num,
case MPCG_STATE_RESET: case MPCG_STATE_RESET:
/* MPC Group is not ready to start XID - min num of */ /* MPC Group is not ready to start XID - min num of */
/* 1 read and 1 write channel have not been acquired*/ /* 1 read and 1 write channel have not been acquired*/
printk(KERN_WARNING "ctcmpc: %s() REJECTED ACTIVE XID Req"
"uest - Channel Pair is not Active\n", __FUNCTION__); CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"%s(%s): REJECTED - inactive channels",
CTCM_FUNTAIL, dev->name);
if (grp->estconnfunc) { if (grp->estconnfunc) {
grp->estconnfunc(grp->port_num, -1, 0); grp->estconnfunc(grp->port_num, -1, 0);
grp->estconnfunc = NULL; grp->estconnfunc = NULL;
...@@ -457,11 +465,12 @@ void ctc_mpc_establish_connectivity(int port_num, ...@@ -457,11 +465,12 @@ void ctc_mpc_establish_connectivity(int port_num,
/* alloc channel was called but no XID exchange */ /* alloc channel was called but no XID exchange */
/* has occurred. initiate xside XID exchange */ /* has occurred. initiate xside XID exchange */
/* make sure yside XID0 processing has not started */ /* make sure yside XID0 processing has not started */
if ((fsm_getstate(rch->fsm) > CH_XID0_PENDING) || if ((fsm_getstate(rch->fsm) > CH_XID0_PENDING) ||
(fsm_getstate(wch->fsm) > CH_XID0_PENDING)) { (fsm_getstate(wch->fsm) > CH_XID0_PENDING)) {
printk(KERN_WARNING "mpc: %s() ABORT ACTIVE XID" CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
" Request- PASSIVE XID in process\n" "%s(%s): ABORT - PASSIVE XID",
, __FUNCTION__); CTCM_FUNTAIL, dev->name);
break; break;
} }
grp->send_qllc_disc = 1; grp->send_qllc_disc = 1;
...@@ -476,9 +485,9 @@ void ctc_mpc_establish_connectivity(int port_num, ...@@ -476,9 +485,9 @@ void ctc_mpc_establish_connectivity(int port_num,
(fsm_getstate(rch->fsm) == CH_XID0_PENDING)) (fsm_getstate(rch->fsm) == CH_XID0_PENDING))
fsm_event(grp->fsm, MPCG_EVENT_XID0DO, rch); fsm_event(grp->fsm, MPCG_EVENT_XID0DO, rch);
else { else {
printk(KERN_WARNING "mpc: %s() Unable to start" CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
" ACTIVE XID0 on read channel\n", "%s(%s): RX-%s not ready for ACTIVE XID0",
__FUNCTION__); CTCM_FUNTAIL, dev->name, rch->id);
if (grp->estconnfunc) { if (grp->estconnfunc) {
grp->estconnfunc(grp->port_num, -1, 0); grp->estconnfunc(grp->port_num, -1, 0);
grp->estconnfunc = NULL; grp->estconnfunc = NULL;
...@@ -490,9 +499,9 @@ void ctc_mpc_establish_connectivity(int port_num, ...@@ -490,9 +499,9 @@ void ctc_mpc_establish_connectivity(int port_num,
(fsm_getstate(wch->fsm) == CH_XID0_PENDING)) (fsm_getstate(wch->fsm) == CH_XID0_PENDING))
fsm_event(grp->fsm, MPCG_EVENT_XID0DO, wch); fsm_event(grp->fsm, MPCG_EVENT_XID0DO, wch);
else { else {
printk(KERN_WARNING "mpc: %s() Unable to start" CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
" ACTIVE XID0 on write channel\n", "%s(%s): WX-%s not ready for ACTIVE XID0",
__FUNCTION__); CTCM_FUNTAIL, dev->name, wch->id);
if (grp->estconnfunc) { if (grp->estconnfunc) {
grp->estconnfunc(grp->port_num, -1, 0); grp->estconnfunc(grp->port_num, -1, 0);
grp->estconnfunc = NULL; grp->estconnfunc = NULL;
...@@ -508,7 +517,7 @@ void ctc_mpc_establish_connectivity(int port_num, ...@@ -508,7 +517,7 @@ void ctc_mpc_establish_connectivity(int port_num,
} }
done: done:
ctcm_pr_debug("ctcmpc exit: %s()\n", __FUNCTION__); CTCM_PR_DEBUG("Exit %s()\n", __func__);
return; return;
} }
EXPORT_SYMBOL(ctc_mpc_establish_connectivity); EXPORT_SYMBOL(ctc_mpc_establish_connectivity);
...@@ -520,40 +529,22 @@ EXPORT_SYMBOL(ctc_mpc_establish_connectivity); ...@@ -520,40 +529,22 @@ EXPORT_SYMBOL(ctc_mpc_establish_connectivity);
void ctc_mpc_dealloc_ch(int port_num) void ctc_mpc_dealloc_ch(int port_num)
{ {
struct net_device *dev; struct net_device *dev;
char device[20];
struct ctcm_priv *priv; struct ctcm_priv *priv;
struct mpc_group *grp; struct mpc_group *grp;
ctcm_pr_debug("ctcmpc enter: %s()\n", __FUNCTION__); dev = ctcmpc_get_dev(port_num);
sprintf(device, "%s%i", MPC_DEVICE_NAME, port_num); if (dev == NULL)
dev = __dev_get_by_name(&init_net, device); return;
priv = dev->priv;
if (dev == NULL) { grp = priv->mpcg;
printk(KERN_INFO "%s() %s dev=NULL\n", __FUNCTION__, device);
goto done;
}
ctcm_pr_debug("ctcmpc:%s %s() called for device %s refcount=%d\n", CTCM_DBF_TEXT_(MPC_SETUP, CTC_DBF_DEBUG,
dev->name, __FUNCTION__, "%s: %s: refcount = %d\n",
dev->name, atomic_read(&dev->refcnt)); CTCM_FUNTAIL, dev->name, atomic_read(&dev->refcnt));
priv = dev->priv;
if (priv == NULL) {
printk(KERN_INFO "%s() %s priv=NULL\n",
__FUNCTION__, device);
goto done;
}
fsm_deltimer(&priv->restart_timer); fsm_deltimer(&priv->restart_timer);
grp = priv->mpcg;
if (grp == NULL) {
printk(KERN_INFO "%s() %s dev=NULL\n", __FUNCTION__, device);
goto done;
}
grp->channels_terminating = 0; grp->channels_terminating = 0;
fsm_deltimer(&grp->timer); fsm_deltimer(&grp->timer);
grp->allochanfunc = NULL; grp->allochanfunc = NULL;
grp->estconnfunc = NULL; grp->estconnfunc = NULL;
grp->port_persist = 0; grp->port_persist = 0;
...@@ -561,8 +552,6 @@ void ctc_mpc_dealloc_ch(int port_num) ...@@ -561,8 +552,6 @@ void ctc_mpc_dealloc_ch(int port_num)
fsm_event(grp->fsm, MPCG_EVENT_INOP, dev); fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
ctcm_close(dev); ctcm_close(dev);
done:
ctcm_pr_debug("ctcmpc exit: %s()\n", __FUNCTION__);
return; return;
} }
EXPORT_SYMBOL(ctc_mpc_dealloc_ch); EXPORT_SYMBOL(ctc_mpc_dealloc_ch);
...@@ -573,32 +562,22 @@ EXPORT_SYMBOL(ctc_mpc_dealloc_ch); ...@@ -573,32 +562,22 @@ EXPORT_SYMBOL(ctc_mpc_dealloc_ch);
*/ */
void ctc_mpc_flow_control(int port_num, int flowc) void ctc_mpc_flow_control(int port_num, int flowc)
{ {
char device[20];
struct ctcm_priv *priv; struct ctcm_priv *priv;
struct mpc_group *grp; struct mpc_group *grp;
struct net_device *dev; struct net_device *dev;
struct channel *rch; struct channel *rch;
int mpcg_state; int mpcg_state;
ctcm_pr_debug("ctcmpc enter: %s() %i\n", __FUNCTION__, flowc); dev = ctcmpc_get_dev(port_num);
if (dev == NULL)
sprintf(device, "%s%i", MPC_DEVICE_NAME, port_num);
dev = __dev_get_by_name(&init_net, device);
if (dev == NULL) {
printk(KERN_INFO "ctc_mpc_flow_control %s dev=NULL\n", device);
return; return;
}
ctcm_pr_debug("ctcmpc: %s %s called \n", dev->name, __FUNCTION__);
priv = dev->priv; priv = dev->priv;
if (priv == NULL) {
printk(KERN_INFO "ctcmpc:%s() %s priv=NULL\n",
__FUNCTION__, device);
return;
}
grp = priv->mpcg; grp = priv->mpcg;
CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_DEBUG,
"%s: %s: flowc = %d",
CTCM_FUNTAIL, dev->name, flowc);
rch = priv->channel[READ]; rch = priv->channel[READ];
mpcg_state = fsm_getstate(grp->fsm); mpcg_state = fsm_getstate(grp->fsm);
...@@ -629,7 +608,6 @@ void ctc_mpc_flow_control(int port_num, int flowc) ...@@ -629,7 +608,6 @@ void ctc_mpc_flow_control(int port_num, int flowc)
break; break;
} }
ctcm_pr_debug("ctcmpc exit: %s() %i\n", __FUNCTION__, flowc);
} }
EXPORT_SYMBOL(ctc_mpc_flow_control); EXPORT_SYMBOL(ctc_mpc_flow_control);
...@@ -646,12 +624,8 @@ static void mpc_rcvd_sweep_resp(struct mpcg_info *mpcginfo) ...@@ -646,12 +624,8 @@ static void mpc_rcvd_sweep_resp(struct mpcg_info *mpcginfo)
struct mpc_group *grp = priv->mpcg; struct mpc_group *grp = priv->mpcg;
struct channel *ch = priv->channel[WRITE]; struct channel *ch = priv->channel[WRITE];
if (do_debug) CTCM_PR_DEBUG("%s: ch=0x%p id=%s\n", __func__, ch, ch->id);
ctcm_pr_debug("ctcmpc enter: %s(): ch=0x%p id=%s\n", CTCM_D3_DUMP((char *)mpcginfo->sweep, TH_SWEEP_LENGTH);
__FUNCTION__, ch, ch->id);
if (do_debug_data)
ctcmpc_dumpit((char *)mpcginfo->sweep, TH_SWEEP_LENGTH);
grp->sweep_rsp_pend_num--; grp->sweep_rsp_pend_num--;
...@@ -684,14 +658,13 @@ static void ctcmpc_send_sweep_resp(struct channel *rch) ...@@ -684,14 +658,13 @@ static void ctcmpc_send_sweep_resp(struct channel *rch)
struct sk_buff *sweep_skb; struct sk_buff *sweep_skb;
struct channel *ch = priv->channel[WRITE]; struct channel *ch = priv->channel[WRITE];
if (do_debug) CTCM_PR_DEBUG("%s: ch=0x%p id=%s\n", __func__, rch, rch->id);
ctcm_pr_debug("ctcmpc exit : %s(): ch=0x%p id=%s\n",
__FUNCTION__, rch, rch->id);
sweep_skb = __dev_alloc_skb(MPC_BUFSIZE_DEFAULT, sweep_skb = __dev_alloc_skb(MPC_BUFSIZE_DEFAULT, GFP_ATOMIC | GFP_DMA);
GFP_ATOMIC|GFP_DMA);
if (sweep_skb == NULL) { if (sweep_skb == NULL) {
printk(KERN_INFO "Couldn't alloc sweep_skb\n"); CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"%s(%s): sweep_skb allocation ERROR\n",
CTCM_FUNTAIL, rch->id);
rc = -ENOMEM; rc = -ENOMEM;
goto done; goto done;
} }
...@@ -746,7 +719,7 @@ static void mpc_rcvd_sweep_req(struct mpcg_info *mpcginfo) ...@@ -746,7 +719,7 @@ static void mpc_rcvd_sweep_req(struct mpcg_info *mpcginfo)
if (do_debug) if (do_debug)
CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_DEBUG, CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_DEBUG,
" %s(): ch=0x%p id=%s\n", __FUNCTION__, ch, ch->id); " %s(): ch=0x%p id=%s\n", __func__, ch, ch->id);
if (grp->in_sweep == 0) { if (grp->in_sweep == 0) {
grp->in_sweep = 1; grp->in_sweep = 1;
...@@ -755,8 +728,7 @@ static void mpc_rcvd_sweep_req(struct mpcg_info *mpcginfo) ...@@ -755,8 +728,7 @@ static void mpc_rcvd_sweep_req(struct mpcg_info *mpcginfo)
grp->sweep_rsp_pend_num = grp->active_channels[READ]; grp->sweep_rsp_pend_num = grp->active_channels[READ];
} }
if (do_debug_data) CTCM_D3_DUMP((char *)mpcginfo->sweep, TH_SWEEP_LENGTH);
ctcmpc_dumpit((char *)mpcginfo->sweep, TH_SWEEP_LENGTH);
grp->sweep_req_pend_num--; grp->sweep_req_pend_num--;
ctcmpc_send_sweep_resp(ch); ctcmpc_send_sweep_resp(ch);
...@@ -875,25 +847,13 @@ static int mpcg_fsm_len = ARRAY_SIZE(mpcg_fsm); ...@@ -875,25 +847,13 @@ static int mpcg_fsm_len = ARRAY_SIZE(mpcg_fsm);
static void mpc_action_go_ready(fsm_instance *fsm, int event, void *arg) static void mpc_action_go_ready(fsm_instance *fsm, int event, void *arg)
{ {
struct net_device *dev = arg; struct net_device *dev = arg;
struct ctcm_priv *priv = NULL; struct ctcm_priv *priv = dev->priv;
struct mpc_group *grp = NULL; struct mpc_group *grp = priv->mpcg;
if (dev == NULL) {
printk(KERN_INFO "%s() dev=NULL\n", __FUNCTION__);
return;
}
ctcm_pr_debug("ctcmpc enter: %s %s()\n", dev->name, __FUNCTION__);
priv = dev->priv;
if (priv == NULL) {
printk(KERN_INFO "%s() priv=NULL\n", __FUNCTION__);
return;
}
grp = priv->mpcg;
if (grp == NULL) { if (grp == NULL) {
printk(KERN_INFO "%s() grp=NULL\n", __FUNCTION__); CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"%s(%s): No MPC group",
CTCM_FUNTAIL, dev->name);
return; return;
} }
...@@ -907,7 +867,12 @@ static void mpc_action_go_ready(fsm_instance *fsm, int event, void *arg) ...@@ -907,7 +867,12 @@ static void mpc_action_go_ready(fsm_instance *fsm, int event, void *arg)
grp->estconnfunc = NULL; grp->estconnfunc = NULL;
} else if (grp->allochanfunc) } else if (grp->allochanfunc)
grp->send_qllc_disc = 1; grp->send_qllc_disc = 1;
goto done;
fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"%s(%s): fails",
CTCM_FUNTAIL, dev->name);
return;
} }
grp->port_persist = 1; grp->port_persist = 1;
...@@ -916,14 +881,7 @@ static void mpc_action_go_ready(fsm_instance *fsm, int event, void *arg) ...@@ -916,14 +881,7 @@ static void mpc_action_go_ready(fsm_instance *fsm, int event, void *arg)
tasklet_hi_schedule(&grp->mpc_tasklet2); tasklet_hi_schedule(&grp->mpc_tasklet2);
ctcm_pr_debug("ctcmpc exit: %s %s()\n", dev->name, __FUNCTION__);
return; return;
done:
fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
ctcm_pr_info("ctcmpc: %s()failure occurred\n", __FUNCTION__);
} }
/* /*
...@@ -933,42 +891,28 @@ static void mpc_action_go_ready(fsm_instance *fsm, int event, void *arg) ...@@ -933,42 +891,28 @@ static void mpc_action_go_ready(fsm_instance *fsm, int event, void *arg)
void mpc_group_ready(unsigned long adev) void mpc_group_ready(unsigned long adev)
{ {
struct net_device *dev = (struct net_device *)adev; struct net_device *dev = (struct net_device *)adev;
struct ctcm_priv *priv = NULL; struct ctcm_priv *priv = dev->priv;
struct mpc_group *grp = NULL; struct mpc_group *grp = priv->mpcg;
struct channel *ch = NULL; struct channel *ch = NULL;
ctcm_pr_debug("ctcmpc enter: %s()\n", __FUNCTION__);
if (dev == NULL) {
printk(KERN_INFO "%s() dev=NULL\n", __FUNCTION__);
return;
}
priv = dev->priv;
if (priv == NULL) {
printk(KERN_INFO "%s() priv=NULL\n", __FUNCTION__);
return;
}
grp = priv->mpcg;
if (grp == NULL) { if (grp == NULL) {
printk(KERN_INFO "ctcmpc:%s() grp=NULL\n", __FUNCTION__); CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"%s(%s): No MPC group",
CTCM_FUNTAIL, dev->name);
return; return;
} }
printk(KERN_NOTICE "ctcmpc: %s GROUP TRANSITIONED TO READY" CTCM_DBF_TEXT_(MPC_SETUP, CTC_DBF_NOTICE,
" maxbuf:%d\n", "%s: %s: GROUP TRANSITIONED TO READY, maxbuf = %d\n",
dev->name, grp->group_max_buflen); CTCM_FUNTAIL, dev->name, grp->group_max_buflen);
fsm_newstate(grp->fsm, MPCG_STATE_READY); fsm_newstate(grp->fsm, MPCG_STATE_READY);
/* Put up a read on the channel */ /* Put up a read on the channel */
ch = priv->channel[READ]; ch = priv->channel[READ];
ch->pdu_seq = 0; ch->pdu_seq = 0;
if (do_debug_data) CTCM_PR_DBGDATA("ctcmpc: %s() ToDCM_pdu_seq= %08x\n" ,
ctcm_pr_debug("ctcmpc: %s() ToDCM_pdu_seq= %08x\n" , __func__, ch->pdu_seq);
__FUNCTION__, ch->pdu_seq);
ctcmpc_chx_rxidle(ch->fsm, CTC_EVENT_START, ch); ctcmpc_chx_rxidle(ch->fsm, CTC_EVENT_START, ch);
/* Put the write channel in idle state */ /* Put the write channel in idle state */
...@@ -980,22 +924,18 @@ void mpc_group_ready(unsigned long adev) ...@@ -980,22 +924,18 @@ void mpc_group_ready(unsigned long adev)
spin_unlock(&ch->collect_lock); spin_unlock(&ch->collect_lock);
} }
ctcm_chx_txidle(ch->fsm, CTC_EVENT_START, ch); ctcm_chx_txidle(ch->fsm, CTC_EVENT_START, ch);
ctcm_clear_busy(dev); ctcm_clear_busy(dev);
if (grp->estconnfunc) { if (grp->estconnfunc) {
grp->estconnfunc(grp->port_num, 0, grp->estconnfunc(grp->port_num, 0,
grp->group_max_buflen); grp->group_max_buflen);
grp->estconnfunc = NULL; grp->estconnfunc = NULL;
} else } else if (grp->allochanfunc)
if (grp->allochanfunc) grp->allochanfunc(grp->port_num, grp->group_max_buflen);
grp->allochanfunc(grp->port_num,
grp->group_max_buflen);
grp->send_qllc_disc = 1; grp->send_qllc_disc = 1;
grp->changed_side = 0; grp->changed_side = 0;
ctcm_pr_debug("ctcmpc exit: %s()\n", __FUNCTION__);
return; return;
} }
...@@ -1004,51 +944,26 @@ void mpc_group_ready(unsigned long adev) ...@@ -1004,51 +944,26 @@ void mpc_group_ready(unsigned long adev)
* Increment the MPC Group Active Channel Counts * Increment the MPC Group Active Channel Counts
* helper of dev_action (called from channel fsm) * helper of dev_action (called from channel fsm)
*/ */
int mpc_channel_action(struct channel *ch, int direction, int action) void mpc_channel_action(struct channel *ch, int direction, int action)
{ {
struct net_device *dev = ch->netdev; struct net_device *dev = ch->netdev;
struct ctcm_priv *priv; struct ctcm_priv *priv = dev->priv;
struct mpc_group *grp = NULL; struct mpc_group *grp = priv->mpcg;
int rc = 0;
if (do_debug)
ctcm_pr_debug("ctcmpc enter: %s(): ch=0x%p id=%s\n",
__FUNCTION__, ch, ch->id);
if (dev == NULL) {
printk(KERN_INFO "ctcmpc_channel_action %i dev=NULL\n",
action);
rc = 1;
goto done;
}
priv = dev->priv;
if (priv == NULL) {
printk(KERN_INFO
"ctcmpc_channel_action%i priv=NULL, dev=%s\n",
action, dev->name);
rc = 2;
goto done;
}
grp = priv->mpcg;
if (grp == NULL) { if (grp == NULL) {
printk(KERN_INFO "ctcmpc: %s()%i mpcgroup=NULL, dev=%s\n", CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
__FUNCTION__, action, dev->name); "%s(%s): No MPC group",
rc = 3; CTCM_FUNTAIL, dev->name);
goto done; return;
} }
ctcm_pr_info( CTCM_PR_DEBUG("enter %s: ch=0x%p id=%s\n", __func__, ch, ch->id);
"ctcmpc: %s() %i(): Grp:%s total_channel_paths=%i "
"active_channels read=%i, write=%i\n", CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_NOTICE,
__FUNCTION__, "%s: %i / Grp:%s total_channels=%i, active_channels: "
action, "read=%i, write=%i\n", __func__, action,
fsm_getstate_str(grp->fsm), fsm_getstate_str(grp->fsm), grp->num_channel_paths,
grp->num_channel_paths, grp->active_channels[READ], grp->active_channels[WRITE]);
grp->active_channels[READ],
grp->active_channels[WRITE]);
if ((action == MPC_CHANNEL_ADD) && (ch->in_mpcgroup == 0)) { if ((action == MPC_CHANNEL_ADD) && (ch->in_mpcgroup == 0)) {
grp->num_channel_paths++; grp->num_channel_paths++;
...@@ -1062,10 +977,11 @@ int mpc_channel_action(struct channel *ch, int direction, int action) ...@@ -1062,10 +977,11 @@ int mpc_channel_action(struct channel *ch, int direction, int action)
ch->xid_skb = __dev_alloc_skb(MPC_BUFSIZE_DEFAULT, ch->xid_skb = __dev_alloc_skb(MPC_BUFSIZE_DEFAULT,
GFP_ATOMIC | GFP_DMA); GFP_ATOMIC | GFP_DMA);
if (ch->xid_skb == NULL) { if (ch->xid_skb == NULL) {
printk(KERN_INFO "ctcmpc: %s()" CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"Couldn't alloc ch xid_skb\n", __FUNCTION__); "%s(%s): Couldn't alloc ch xid_skb\n",
CTCM_FUNTAIL, dev->name);
fsm_event(grp->fsm, MPCG_EVENT_INOP, dev); fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
return 1; return;
} }
ch->xid_skb_data = ch->xid_skb->data; ch->xid_skb_data = ch->xid_skb->data;
ch->xid_th = (struct th_header *)ch->xid_skb->data; ch->xid_th = (struct th_header *)ch->xid_skb->data;
...@@ -1097,8 +1013,9 @@ int mpc_channel_action(struct channel *ch, int direction, int action) ...@@ -1097,8 +1013,9 @@ int mpc_channel_action(struct channel *ch, int direction, int action)
(grp->active_channels[WRITE] > 0) && (grp->active_channels[WRITE] > 0) &&
(fsm_getstate(grp->fsm) < MPCG_STATE_XID2INITW)) { (fsm_getstate(grp->fsm) < MPCG_STATE_XID2INITW)) {
fsm_newstate(grp->fsm, MPCG_STATE_XID2INITW); fsm_newstate(grp->fsm, MPCG_STATE_XID2INITW);
printk(KERN_NOTICE "ctcmpc: %s MPC GROUP " CTCM_DBF_TEXT_(MPC_SETUP, CTC_DBF_NOTICE,
"CHANNELS ACTIVE\n", dev->name); "%s: %s: MPC GROUP CHANNELS ACTIVE\n",
__func__, dev->name);
} }
} else if ((action == MPC_CHANNEL_REMOVE) && } else if ((action == MPC_CHANNEL_REMOVE) &&
(ch->in_mpcgroup == 1)) { (ch->in_mpcgroup == 1)) {
...@@ -1119,25 +1036,14 @@ int mpc_channel_action(struct channel *ch, int direction, int action) ...@@ -1119,25 +1036,14 @@ int mpc_channel_action(struct channel *ch, int direction, int action)
(grp->active_channels[READ] > 0))) (grp->active_channels[READ] > 0)))
fsm_event(grp->fsm, MPCG_EVENT_INOP, dev); fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
} }
done: done:
CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_DEBUG,
"exit %s: %i / Grp:%s total_channels=%i, active_channels: "
"read=%i, write=%i\n", __func__, action,
fsm_getstate_str(grp->fsm), grp->num_channel_paths,
grp->active_channels[READ], grp->active_channels[WRITE]);
if (do_debug) { CTCM_PR_DEBUG("exit %s: ch=0x%p id=%s\n", __func__, ch, ch->id);
ctcm_pr_debug(
"ctcmpc: %s() %i Grp:%s ttl_chan_paths=%i "
"active_chans read=%i, write=%i\n",
__FUNCTION__,
action,
fsm_getstate_str(grp->fsm),
grp->num_channel_paths,
grp->active_channels[READ],
grp->active_channels[WRITE]);
ctcm_pr_debug("ctcmpc exit : %s(): ch=0x%p id=%s\n",
__FUNCTION__, ch, ch->id);
}
return rc;
} }
/** /**
...@@ -1163,9 +1069,8 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb) ...@@ -1163,9 +1069,8 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb)
int skblen; int skblen;
int sendrc = 0; int sendrc = 0;
if (do_debug) CTCM_PR_DEBUG("ctcmpc enter: %s() %s cp:%i ch:%s\n",
ctcm_pr_debug("ctcmpc enter: %s() %s cp:%i ch:%s\n", __func__, dev->name, smp_processor_id(), ch->id);
__FUNCTION__, dev->name, smp_processor_id(), ch->id);
header = (struct th_header *)pskb->data; header = (struct th_header *)pskb->data;
if ((header->th_seg == 0) && if ((header->th_seg == 0) &&
...@@ -1174,21 +1079,16 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb) ...@@ -1174,21 +1079,16 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb)
(header->th_seq_num == 0)) (header->th_seq_num == 0))
/* nothing for us */ goto done; /* nothing for us */ goto done;
if (do_debug_data) { CTCM_PR_DBGDATA("%s: th_header\n", __func__);
ctcm_pr_debug("ctcmpc: %s() th_header\n", __FUNCTION__); CTCM_D3_DUMP((char *)header, TH_HEADER_LENGTH);
ctcmpc_dumpit((char *)header, TH_HEADER_LENGTH); CTCM_PR_DBGDATA("%s: pskb len: %04x \n", __func__, pskb->len);
ctcm_pr_debug("ctcmpc: %s() pskb len: %04x \n",
__FUNCTION__, pskb->len);
}
pskb->dev = dev; pskb->dev = dev;
pskb->ip_summed = CHECKSUM_UNNECESSARY; pskb->ip_summed = CHECKSUM_UNNECESSARY;
skb_pull(pskb, TH_HEADER_LENGTH); skb_pull(pskb, TH_HEADER_LENGTH);
if (likely(header->th_ch_flag == TH_HAS_PDU)) { if (likely(header->th_ch_flag == TH_HAS_PDU)) {
if (do_debug_data) CTCM_PR_DBGDATA("%s: came into th_has_pdu\n", __func__);
ctcm_pr_debug("ctcmpc: %s() came into th_has_pdu\n",
__FUNCTION__);
if ((fsm_getstate(grp->fsm) == MPCG_STATE_FLOWC) || if ((fsm_getstate(grp->fsm) == MPCG_STATE_FLOWC) ||
((fsm_getstate(grp->fsm) == MPCG_STATE_READY) && ((fsm_getstate(grp->fsm) == MPCG_STATE_READY) &&
(header->th_seq_num != ch->th_seq_num + 1) && (header->th_seq_num != ch->th_seq_num + 1) &&
...@@ -1202,9 +1102,8 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb) ...@@ -1202,9 +1102,8 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb)
grp->out_of_sequence += 1; grp->out_of_sequence += 1;
__skb_push(pskb, TH_HEADER_LENGTH); __skb_push(pskb, TH_HEADER_LENGTH);
skb_queue_tail(&ch->io_queue, pskb); skb_queue_tail(&ch->io_queue, pskb);
if (do_debug_data) CTCM_PR_DBGDATA("%s: th_seq_num expect:%08x "
ctcm_pr_debug("ctcmpc: %s() th_seq_num " "got:%08x\n", __func__,
"expect:%08x got:%08x\n", __FUNCTION__,
ch->th_seq_num + 1, header->th_seq_num); ch->th_seq_num + 1, header->th_seq_num);
return; return;
...@@ -1212,23 +1111,20 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb) ...@@ -1212,23 +1111,20 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb)
grp->out_of_sequence = 0; grp->out_of_sequence = 0;
ch->th_seq_num = header->th_seq_num; ch->th_seq_num = header->th_seq_num;
if (do_debug_data) CTCM_PR_DBGDATA("ctcmpc: %s() FromVTAM_th_seq=%08x\n",
ctcm_pr_debug("ctcmpc: %s() FromVTAM_th_seq=%08x\n", __func__, ch->th_seq_num);
__FUNCTION__, ch->th_seq_num);
if (unlikely(fsm_getstate(grp->fsm) != MPCG_STATE_READY)) if (unlikely(fsm_getstate(grp->fsm) != MPCG_STATE_READY))
goto done; goto done;
pdu_last_seen = 0; pdu_last_seen = 0;
while ((pskb->len > 0) && !pdu_last_seen) { while ((pskb->len > 0) && !pdu_last_seen) {
curr_pdu = (struct pdu *)pskb->data; curr_pdu = (struct pdu *)pskb->data;
if (do_debug_data) {
ctcm_pr_debug("ctcm: %s() pdu_header\n", CTCM_PR_DBGDATA("%s: pdu_header\n", __func__);
__FUNCTION__); CTCM_D3_DUMP((char *)pskb->data, PDU_HEADER_LENGTH);
ctcmpc_dumpit((char *)pskb->data, CTCM_PR_DBGDATA("%s: pskb len: %04x \n",
PDU_HEADER_LENGTH); __func__, pskb->len);
ctcm_pr_debug("ctcm: %s() pskb len: %04x \n",
__FUNCTION__, pskb->len);
}
skb_pull(pskb, PDU_HEADER_LENGTH); skb_pull(pskb, PDU_HEADER_LENGTH);
if (curr_pdu->pdu_flag & PDU_LAST) if (curr_pdu->pdu_flag & PDU_LAST)
...@@ -1239,46 +1135,39 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb) ...@@ -1239,46 +1135,39 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb)
pskb->protocol = htons(ETH_P_SNA_DIX); pskb->protocol = htons(ETH_P_SNA_DIX);
if ((pskb->len <= 0) || (pskb->len > ch->max_bufsize)) { if ((pskb->len <= 0) || (pskb->len > ch->max_bufsize)) {
printk(KERN_INFO CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"%s Illegal packet size %d " "%s(%s): Dropping packet with "
"received " "illegal siize %d",
"dropping\n", dev->name, CTCM_FUNTAIL, dev->name, pskb->len);
pskb->len);
priv->stats.rx_dropped++; priv->stats.rx_dropped++;
priv->stats.rx_length_errors++; priv->stats.rx_length_errors++;
goto done; goto done;
} }
skb_reset_mac_header(pskb); skb_reset_mac_header(pskb);
new_len = curr_pdu->pdu_offset; new_len = curr_pdu->pdu_offset;
if (do_debug_data) CTCM_PR_DBGDATA("%s: new_len: %04x \n",
ctcm_pr_debug("ctcmpc: %s() new_len: %04x \n", __func__, new_len);
__FUNCTION__, new_len);
if ((new_len == 0) || (new_len > pskb->len)) { if ((new_len == 0) || (new_len > pskb->len)) {
/* should never happen */ /* should never happen */
/* pskb len must be hosed...bail out */ /* pskb len must be hosed...bail out */
printk(KERN_INFO CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"ctcmpc: %s(): invalid pdu" "%s(%s): non valid pdu_offset: %04x",
" offset of %04x - data may be" /* "data may be lost", */
"lost\n", __FUNCTION__, new_len); CTCM_FUNTAIL, dev->name, new_len);
goto done; goto done;
} }
skb = __dev_alloc_skb(new_len+4, GFP_ATOMIC); skb = __dev_alloc_skb(new_len+4, GFP_ATOMIC);
if (!skb) { if (!skb) {
printk(KERN_INFO CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"ctcm: %s Out of memory in " "%s(%s): MEMORY allocation error",
"%s()- request-len:%04x \n", CTCM_FUNTAIL, dev->name);
dev->name,
__FUNCTION__,
new_len+4);
priv->stats.rx_dropped++; priv->stats.rx_dropped++;
fsm_event(grp->fsm, fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
MPCG_EVENT_INOP, dev);
goto done; goto done;
} }
memcpy(skb_put(skb, new_len), pskb->data, new_len);
memcpy(skb_put(skb, new_len),
pskb->data, new_len);
skb_reset_mac_header(skb); skb_reset_mac_header(skb);
skb->dev = pskb->dev; skb->dev = pskb->dev;
...@@ -1287,17 +1176,14 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb) ...@@ -1287,17 +1176,14 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb)
*((__u32 *) skb_push(skb, 4)) = ch->pdu_seq; *((__u32 *) skb_push(skb, 4)) = ch->pdu_seq;
ch->pdu_seq++; ch->pdu_seq++;
if (do_debug_data) if (do_debug_data) {
ctcm_pr_debug("%s: ToDCM_pdu_seq= %08x\n", ctcm_pr_debug("%s: ToDCM_pdu_seq= %08x\n",
__FUNCTION__, ch->pdu_seq); __func__, ch->pdu_seq);
ctcm_pr_debug("%s: skb:%0lx "
ctcm_pr_debug("ctcm: %s() skb:%0lx " "skb len: %d \n", __func__,
"skb len: %d \n", __FUNCTION__,
(unsigned long)skb, skb->len); (unsigned long)skb, skb->len);
if (do_debug_data) { ctcm_pr_debug("%s: up to 32 bytes "
ctcm_pr_debug("ctcmpc: %s() up to 32 bytes" "of pdu_data sent\n", __func__);
" of pdu_data sent\n",
__FUNCTION__);
ctcmpc_dump32((char *)skb->data, skb->len); ctcmpc_dump32((char *)skb->data, skb->len);
} }
...@@ -1316,8 +1202,8 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb) ...@@ -1316,8 +1202,8 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb)
mpcginfo->ch = ch; mpcginfo->ch = ch;
mpcginfo->th = header; mpcginfo->th = header;
mpcginfo->skb = pskb; mpcginfo->skb = pskb;
ctcm_pr_debug("ctcmpc: %s() Not PDU - may be control pkt\n", CTCM_PR_DEBUG("%s: Not PDU - may be control pkt\n",
__FUNCTION__); __func__);
/* it's a sweep? */ /* it's a sweep? */
sweep = (struct th_sweep *)pskb->data; sweep = (struct th_sweep *)pskb->data;
mpcginfo->sweep = sweep; mpcginfo->sweep = sweep;
...@@ -1333,8 +1219,9 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb) ...@@ -1333,8 +1219,9 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb)
} else if (header->th_blk_flag == TH_DISCONTACT) } else if (header->th_blk_flag == TH_DISCONTACT)
fsm_event(grp->fsm, MPCG_EVENT_DISCONC, mpcginfo); fsm_event(grp->fsm, MPCG_EVENT_DISCONC, mpcginfo);
else if (header->th_seq_num != 0) { else if (header->th_seq_num != 0) {
printk(KERN_INFO "%s unexpected packet" CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
" expected control pkt\n", dev->name); "%s(%s): control pkt expected\n",
CTCM_FUNTAIL, dev->name);
priv->stats.rx_dropped++; priv->stats.rx_dropped++;
/* mpcginfo only used for non-data transfers */ /* mpcginfo only used for non-data transfers */
kfree(mpcginfo); kfree(mpcginfo);
...@@ -1347,13 +1234,12 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb) ...@@ -1347,13 +1234,12 @@ static void ctcmpc_unpack_skb(struct channel *ch, struct sk_buff *pskb)
dev_kfree_skb_any(pskb); dev_kfree_skb_any(pskb);
if (sendrc == NET_RX_DROP) { if (sendrc == NET_RX_DROP) {
printk(KERN_WARNING "%s %s() NETWORK BACKLOG EXCEEDED" printk(KERN_WARNING "%s %s() NETWORK BACKLOG EXCEEDED"
" - PACKET DROPPED\n", dev->name, __FUNCTION__); " - PACKET DROPPED\n", dev->name, __func__);
fsm_event(grp->fsm, MPCG_EVENT_INOP, dev); fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
} }
if (do_debug) CTCM_PR_DEBUG("exit %s: %s: ch=0x%p id=%s\n",
ctcm_pr_debug("ctcmpc exit : %s %s(): ch=0x%p id=%s\n", __func__, dev->name, ch, ch->id);
dev->name, __FUNCTION__, ch, ch->id);
} }
/** /**
...@@ -1372,9 +1258,8 @@ void ctcmpc_bh(unsigned long thischan) ...@@ -1372,9 +1258,8 @@ void ctcmpc_bh(unsigned long thischan)
struct ctcm_priv *priv = dev->priv; struct ctcm_priv *priv = dev->priv;
struct mpc_group *grp = priv->mpcg; struct mpc_group *grp = priv->mpcg;
if (do_debug) CTCM_PR_DEBUG("%s cp:%i enter: %s() %s\n",
ctcm_pr_debug("%s cp:%i enter: %s() %s\n", dev->name, smp_processor_id(), __func__, ch->id);
dev->name, smp_processor_id(), __FUNCTION__, ch->id);
/* caller has requested driver to throttle back */ /* caller has requested driver to throttle back */
while ((fsm_getstate(grp->fsm) != MPCG_STATE_FLOWC) && while ((fsm_getstate(grp->fsm) != MPCG_STATE_FLOWC) &&
(skb = skb_dequeue(&ch->io_queue))) { (skb = skb_dequeue(&ch->io_queue))) {
...@@ -1390,9 +1275,8 @@ void ctcmpc_bh(unsigned long thischan) ...@@ -1390,9 +1275,8 @@ void ctcmpc_bh(unsigned long thischan)
if (skb == skb_peek(&ch->io_queue)) if (skb == skb_peek(&ch->io_queue))
break; break;
} }
if (do_debug) CTCM_PR_DEBUG("exit %s: %s: ch=0x%p id=%s\n",
ctcm_pr_debug("ctcmpc exit : %s %s(): ch=0x%p id=%s\n", __func__, dev->name, ch, ch->id);
dev->name, __FUNCTION__, ch, ch->id);
return; return;
} }
...@@ -1403,14 +1287,14 @@ struct mpc_group *ctcmpc_init_mpc_group(struct ctcm_priv *priv) ...@@ -1403,14 +1287,14 @@ struct mpc_group *ctcmpc_init_mpc_group(struct ctcm_priv *priv)
{ {
struct mpc_group *grp; struct mpc_group *grp;
CTCM_DBF_TEXT(MPC_SETUP, 3, __FUNCTION__); CTCM_DBF_TEXT_(MPC_SETUP, CTC_DBF_INFO,
"Enter %s(%p)", CTCM_FUNTAIL, priv);
grp = kzalloc(sizeof(struct mpc_group), GFP_KERNEL); grp = kzalloc(sizeof(struct mpc_group), GFP_KERNEL);
if (grp == NULL) if (grp == NULL)
return NULL; return NULL;
grp->fsm = grp->fsm = init_fsm("mpcg", mpcg_state_names, mpcg_event_names,
init_fsm("mpcg", mpcg_state_names, mpcg_event_names,
MPCG_NR_STATES, MPCG_NR_EVENTS, mpcg_fsm, MPCG_NR_STATES, MPCG_NR_EVENTS, mpcg_fsm,
mpcg_fsm_len, GFP_KERNEL); mpcg_fsm_len, GFP_KERNEL);
if (grp->fsm == NULL) { if (grp->fsm == NULL) {
...@@ -1424,7 +1308,6 @@ struct mpc_group *ctcmpc_init_mpc_group(struct ctcm_priv *priv) ...@@ -1424,7 +1308,6 @@ struct mpc_group *ctcmpc_init_mpc_group(struct ctcm_priv *priv)
grp->xid_skb = grp->xid_skb =
__dev_alloc_skb(MPC_BUFSIZE_DEFAULT, GFP_ATOMIC | GFP_DMA); __dev_alloc_skb(MPC_BUFSIZE_DEFAULT, GFP_ATOMIC | GFP_DMA);
if (grp->xid_skb == NULL) { if (grp->xid_skb == NULL) {
printk(KERN_INFO "Couldn't alloc MPCgroup xid_skb\n");
kfree_fsm(grp->fsm); kfree_fsm(grp->fsm);
kfree(grp); kfree(grp);
return NULL; return NULL;
...@@ -1435,7 +1318,7 @@ struct mpc_group *ctcmpc_init_mpc_group(struct ctcm_priv *priv) ...@@ -1435,7 +1318,7 @@ struct mpc_group *ctcmpc_init_mpc_group(struct ctcm_priv *priv)
memcpy(skb_put(grp->xid_skb, TH_HEADER_LENGTH), memcpy(skb_put(grp->xid_skb, TH_HEADER_LENGTH),
&thnorm, TH_HEADER_LENGTH); &thnorm, TH_HEADER_LENGTH);
grp->xid = (struct xid2 *) skb_tail_pointer(grp->xid_skb); grp->xid = (struct xid2 *)skb_tail_pointer(grp->xid_skb);
memcpy(skb_put(grp->xid_skb, XID2_LENGTH), &init_xid, XID2_LENGTH); memcpy(skb_put(grp->xid_skb, XID2_LENGTH), &init_xid, XID2_LENGTH);
grp->xid->xid2_adj_id = jiffies | 0xfff00000; grp->xid->xid2_adj_id = jiffies | 0xfff00000;
grp->xid->xid2_sender_id = jiffies; grp->xid->xid2_sender_id = jiffies;
...@@ -1446,7 +1329,6 @@ struct mpc_group *ctcmpc_init_mpc_group(struct ctcm_priv *priv) ...@@ -1446,7 +1329,6 @@ struct mpc_group *ctcmpc_init_mpc_group(struct ctcm_priv *priv)
grp->rcvd_xid_skb = grp->rcvd_xid_skb =
__dev_alloc_skb(MPC_BUFSIZE_DEFAULT, GFP_ATOMIC|GFP_DMA); __dev_alloc_skb(MPC_BUFSIZE_DEFAULT, GFP_ATOMIC|GFP_DMA);
if (grp->rcvd_xid_skb == NULL) { if (grp->rcvd_xid_skb == NULL) {
printk(KERN_INFO "Couldn't alloc MPCgroup rcvd_xid_skb\n");
kfree_fsm(grp->fsm); kfree_fsm(grp->fsm);
dev_kfree_skb(grp->xid_skb); dev_kfree_skb(grp->xid_skb);
kfree(grp); kfree(grp);
...@@ -1492,28 +1374,23 @@ static void mpc_action_go_inop(fsm_instance *fi, int event, void *arg) ...@@ -1492,28 +1374,23 @@ static void mpc_action_go_inop(fsm_instance *fi, int event, void *arg)
int rc = 0; int rc = 0;
struct channel *wch, *rch; struct channel *wch, *rch;
if (dev == NULL) { BUG_ON(dev == NULL);
printk(KERN_INFO "%s() dev=NULL\n", __FUNCTION__); CTCM_PR_DEBUG("Enter %s: %s\n", __func__, dev->name);
return;
}
ctcm_pr_debug("ctcmpc enter: %s %s()\n", dev->name, __FUNCTION__);
priv = dev->priv; priv = dev->priv;
grp = priv->mpcg; grp = priv->mpcg;
grp->flow_off_called = 0; grp->flow_off_called = 0;
fsm_deltimer(&grp->timer); fsm_deltimer(&grp->timer);
if (grp->channels_terminating) if (grp->channels_terminating)
goto done; return;
grp->channels_terminating = 1; grp->channels_terminating = 1;
grp->saved_state = fsm_getstate(grp->fsm); grp->saved_state = fsm_getstate(grp->fsm);
fsm_newstate(grp->fsm, MPCG_STATE_INOP); fsm_newstate(grp->fsm, MPCG_STATE_INOP);
if (grp->saved_state > MPCG_STATE_XID7INITF) if (grp->saved_state > MPCG_STATE_XID7INITF)
printk(KERN_NOTICE "%s:MPC GROUP INOPERATIVE\n", dev->name); CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_NOTICE,
"%s(%s): MPC GROUP INOPERATIVE",
CTCM_FUNTAIL, dev->name);
if ((grp->saved_state != MPCG_STATE_RESET) || if ((grp->saved_state != MPCG_STATE_RESET) ||
/* dealloc_channel has been called */ /* dealloc_channel has been called */
((grp->saved_state == MPCG_STATE_RESET) && ((grp->saved_state == MPCG_STATE_RESET) &&
...@@ -1567,29 +1444,24 @@ static void mpc_action_go_inop(fsm_instance *fi, int event, void *arg) ...@@ -1567,29 +1444,24 @@ static void mpc_action_go_inop(fsm_instance *fi, int event, void *arg)
/* This can result in INOP of VTAM PU due to halting of */ /* This can result in INOP of VTAM PU due to halting of */
/* outstanding IO which causes a sense to be returned */ /* outstanding IO which causes a sense to be returned */
/* Only about 3 senses are allowed and then IOS/VTAM will*/ /* Only about 3 senses are allowed and then IOS/VTAM will*/
/* ebcome unreachable without manual intervention */ /* become unreachable without manual intervention */
if ((grp->port_persist == 1) || (grp->alloc_called)) { if ((grp->port_persist == 1) || (grp->alloc_called)) {
grp->alloc_called = 0; grp->alloc_called = 0;
fsm_deltimer(&priv->restart_timer); fsm_deltimer(&priv->restart_timer);
fsm_addtimer(&priv->restart_timer, fsm_addtimer(&priv->restart_timer, 500, DEV_EVENT_RESTART, dev);
500,
DEV_EVENT_RESTART,
dev);
fsm_newstate(grp->fsm, MPCG_STATE_RESET); fsm_newstate(grp->fsm, MPCG_STATE_RESET);
if (grp->saved_state > MPCG_STATE_XID7INITF) if (grp->saved_state > MPCG_STATE_XID7INITF)
printk(KERN_NOTICE "%s:MPC GROUP RECOVERY SCHEDULED\n", CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_ALWAYS,
dev->name); "%s(%s): MPC GROUP RECOVERY SCHEDULED",
CTCM_FUNTAIL, dev->name);
} else { } else {
fsm_deltimer(&priv->restart_timer); fsm_deltimer(&priv->restart_timer);
fsm_addtimer(&priv->restart_timer, 500, DEV_EVENT_STOP, dev); fsm_addtimer(&priv->restart_timer, 500, DEV_EVENT_STOP, dev);
fsm_newstate(grp->fsm, MPCG_STATE_RESET); fsm_newstate(grp->fsm, MPCG_STATE_RESET);
printk(KERN_NOTICE "%s:MPC GROUP RECOVERY NOT ATTEMPTED\n", CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_ALWAYS,
dev->name); "%s(%s): NO MPC GROUP RECOVERY ATTEMPTED",
CTCM_FUNTAIL, dev->name);
} }
done:
ctcm_pr_debug("ctcmpc exit:%s %s()\n", dev->name, __FUNCTION__);
return;
} }
/** /**
...@@ -1609,12 +1481,7 @@ static void mpc_action_timeout(fsm_instance *fi, int event, void *arg) ...@@ -1609,12 +1481,7 @@ static void mpc_action_timeout(fsm_instance *fi, int event, void *arg)
struct channel *wch; struct channel *wch;
struct channel *rch; struct channel *rch;
CTCM_DBF_TEXT(MPC_TRACE, 6, __FUNCTION__); BUG_ON(dev == NULL);
if (dev == NULL) {
CTCM_DBF_TEXT_(MPC_ERROR, 4, "%s: dev=NULL\n", __FUNCTION__);
return;
}
priv = dev->priv; priv = dev->priv;
grp = priv->mpcg; grp = priv->mpcg;
...@@ -1633,8 +1500,9 @@ static void mpc_action_timeout(fsm_instance *fi, int event, void *arg) ...@@ -1633,8 +1500,9 @@ static void mpc_action_timeout(fsm_instance *fi, int event, void *arg)
fsm_event(grp->fsm, MPCG_EVENT_INOP, dev); fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
} }
CTCM_DBF_TEXT_(MPC_TRACE, 6, "%s: dev=%s exit", CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_DEBUG,
__FUNCTION__, dev->name); "%s: dev=%s exit",
CTCM_FUNTAIL, dev->name);
return; return;
} }
...@@ -1646,25 +1514,25 @@ void mpc_action_discontact(fsm_instance *fi, int event, void *arg) ...@@ -1646,25 +1514,25 @@ void mpc_action_discontact(fsm_instance *fi, int event, void *arg)
{ {
struct mpcg_info *mpcginfo = arg; struct mpcg_info *mpcginfo = arg;
struct channel *ch = mpcginfo->ch; struct channel *ch = mpcginfo->ch;
struct net_device *dev = ch->netdev; struct net_device *dev;
struct ctcm_priv *priv = dev->priv; struct ctcm_priv *priv;
struct mpc_group *grp = priv->mpcg; struct mpc_group *grp;
if (ch == NULL) {
printk(KERN_INFO "%s() ch=NULL\n", __FUNCTION__);
return;
}
if (ch->netdev == NULL) {
printk(KERN_INFO "%s() dev=NULL\n", __FUNCTION__);
return;
}
ctcm_pr_debug("ctcmpc enter: %s %s()\n", dev->name, __FUNCTION__);
if (ch) {
dev = ch->netdev;
if (dev) {
priv = dev->priv;
if (priv) {
CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_NOTICE,
"%s: %s: %s\n",
CTCM_FUNTAIL, dev->name, ch->id);
grp = priv->mpcg;
grp->send_qllc_disc = 1; grp->send_qllc_disc = 1;
fsm_event(grp->fsm, MPCG_EVENT_INOP, dev); fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
}
}
}
ctcm_pr_debug("ctcmpc exit: %s %s()\n", dev->name, __FUNCTION__);
return; return;
} }
...@@ -1675,26 +1543,9 @@ void mpc_action_discontact(fsm_instance *fi, int event, void *arg) ...@@ -1675,26 +1543,9 @@ void mpc_action_discontact(fsm_instance *fi, int event, void *arg)
*/ */
void mpc_action_send_discontact(unsigned long thischan) void mpc_action_send_discontact(unsigned long thischan)
{ {
struct channel *ch; int rc;
struct net_device *dev; struct channel *ch = (struct channel *)thischan;
struct ctcm_priv *priv; unsigned long saveflags = 0;
struct mpc_group *grp;
int rc = 0;
unsigned long saveflags;
ch = (struct channel *)thischan;
dev = ch->netdev;
priv = dev->priv;
grp = priv->mpcg;
ctcm_pr_info("ctcmpc: %s cp:%i enter: %s() GrpState:%s ChState:%s\n",
dev->name,
smp_processor_id(),
__FUNCTION__,
fsm_getstate_str(grp->fsm),
fsm_getstate_str(ch->fsm));
saveflags = 0; /* avoids compiler warning with
spin_unlock_irqrestore */
spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags); spin_lock_irqsave(get_ccwdev_lock(ch->cdev), saveflags);
rc = ccw_device_start(ch->cdev, &ch->ccw[15], rc = ccw_device_start(ch->cdev, &ch->ccw[15],
...@@ -1702,16 +1553,9 @@ void mpc_action_send_discontact(unsigned long thischan) ...@@ -1702,16 +1553,9 @@ void mpc_action_send_discontact(unsigned long thischan)
spin_unlock_irqrestore(get_ccwdev_lock(ch->cdev), saveflags); spin_unlock_irqrestore(get_ccwdev_lock(ch->cdev), saveflags);
if (rc != 0) { if (rc != 0) {
ctcm_pr_info("ctcmpc: %s() ch:%s IO failed \n", ctcm_ccw_check_rc(ch, rc, (char *)__func__);
__FUNCTION__,
ch->id);
ctcm_ccw_check_rc(ch, rc, "send discontact");
/* Not checking return code value here */
/* Making best effort to notify partner*/
/* that MPC Group is going down */
} }
ctcm_pr_debug("ctcmpc exit: %s %s()\n", dev->name, __FUNCTION__);
return; return;
} }
...@@ -1728,43 +1572,44 @@ static int mpc_validate_xid(struct mpcg_info *mpcginfo) ...@@ -1728,43 +1572,44 @@ static int mpc_validate_xid(struct mpcg_info *mpcginfo)
struct ctcm_priv *priv = dev->priv; struct ctcm_priv *priv = dev->priv;
struct mpc_group *grp = priv->mpcg; struct mpc_group *grp = priv->mpcg;
struct xid2 *xid = mpcginfo->xid; struct xid2 *xid = mpcginfo->xid;
int failed = 0;
int rc = 0; int rc = 0;
__u64 our_id, their_id = 0; __u64 our_id = 0;
int len; __u64 their_id = 0;
int len = TH_HEADER_LENGTH + PDU_HEADER_LENGTH;
len = TH_HEADER_LENGTH + PDU_HEADER_LENGTH;
ctcm_pr_debug("ctcmpc enter: %s()\n", __FUNCTION__); CTCM_PR_DEBUG("Enter %s: xid=%p\n", __func__, xid);
if (mpcginfo->xid == NULL) { if (xid == NULL) {
printk(KERN_INFO "%s() xid=NULL\n", __FUNCTION__);
rc = 1; rc = 1;
/* XID REJECTED: xid == NULL */
CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"%s(%s): xid = NULL",
CTCM_FUNTAIL, ch->id);
goto done; goto done;
} }
ctcm_pr_debug("ctcmpc : %s xid received()\n", __FUNCTION__); CTCM_D3_DUMP((char *)xid, XID2_LENGTH);
ctcmpc_dumpit((char *)mpcginfo->xid, XID2_LENGTH);
/*the received direction should be the opposite of ours */ /*the received direction should be the opposite of ours */
if (((CHANNEL_DIRECTION(ch->flags) == READ) ? XID2_WRITE_SIDE : if (((CHANNEL_DIRECTION(ch->flags) == READ) ? XID2_WRITE_SIDE :
XID2_READ_SIDE) != xid->xid2_dlc_type) { XID2_READ_SIDE) != xid->xid2_dlc_type) {
failed = 1; rc = 2;
printk(KERN_INFO "ctcmpc:%s() XID REJECTED - READ-WRITE CH " /* XID REJECTED: r/w channel pairing mismatch */
"Pairing Invalid \n", __FUNCTION__); CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"%s(%s): r/w channel pairing mismatch",
CTCM_FUNTAIL, ch->id);
goto done;
} }
if (xid->xid2_dlc_type == XID2_READ_SIDE) { if (xid->xid2_dlc_type == XID2_READ_SIDE) {
ctcm_pr_debug("ctcmpc: %s(): grpmaxbuf:%d xid2buflen:%d\n", CTCM_PR_DEBUG("%s: grpmaxbuf:%d xid2buflen:%d\n", __func__,
__FUNCTION__, grp->group_max_buflen, grp->group_max_buflen, xid->xid2_buf_len);
xid->xid2_buf_len);
if (grp->group_max_buflen == 0 || if (grp->group_max_buflen == 0 || grp->group_max_buflen >
grp->group_max_buflen > xid->xid2_buf_len - len) xid->xid2_buf_len - len)
grp->group_max_buflen = xid->xid2_buf_len - len; grp->group_max_buflen = xid->xid2_buf_len - len;
} }
if (grp->saved_xid2 == NULL) { if (grp->saved_xid2 == NULL) {
grp->saved_xid2 = grp->saved_xid2 =
(struct xid2 *)skb_tail_pointer(grp->rcvd_xid_skb); (struct xid2 *)skb_tail_pointer(grp->rcvd_xid_skb);
...@@ -1786,49 +1631,54 @@ static int mpc_validate_xid(struct mpcg_info *mpcginfo) ...@@ -1786,49 +1631,54 @@ static int mpc_validate_xid(struct mpcg_info *mpcginfo)
/* lower id assume the xside role */ /* lower id assume the xside role */
if (our_id < their_id) { if (our_id < their_id) {
grp->roll = XSIDE; grp->roll = XSIDE;
ctcm_pr_debug("ctcmpc :%s() WE HAVE LOW ID-" CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_NOTICE,
"TAKE XSIDE\n", __FUNCTION__); "%s(%s): WE HAVE LOW ID - TAKE XSIDE",
CTCM_FUNTAIL, ch->id);
} else { } else {
grp->roll = YSIDE; grp->roll = YSIDE;
ctcm_pr_debug("ctcmpc :%s() WE HAVE HIGH ID-" CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_NOTICE,
"TAKE YSIDE\n", __FUNCTION__); "%s(%s): WE HAVE HIGH ID - TAKE YSIDE",
CTCM_FUNTAIL, ch->id);
} }
} else { } else {
if (xid->xid2_flag4 != grp->saved_xid2->xid2_flag4) { if (xid->xid2_flag4 != grp->saved_xid2->xid2_flag4) {
failed = 1; rc = 3;
printk(KERN_INFO "%s XID REJECTED - XID Flag Byte4\n", /* XID REJECTED: xid flag byte4 mismatch */
__FUNCTION__); CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"%s(%s): xid flag byte4 mismatch",
CTCM_FUNTAIL, ch->id);
} }
if (xid->xid2_flag2 == 0x40) { if (xid->xid2_flag2 == 0x40) {
failed = 1; rc = 4;
printk(KERN_INFO "%s XID REJECTED - XID NOGOOD\n", /* XID REJECTED - xid NOGOOD */
__FUNCTION__); CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"%s(%s): xid NOGOOD",
CTCM_FUNTAIL, ch->id);
} }
if (xid->xid2_adj_id != grp->saved_xid2->xid2_adj_id) { if (xid->xid2_adj_id != grp->saved_xid2->xid2_adj_id) {
failed = 1; rc = 5;
printk(KERN_INFO "%s XID REJECTED - " /* XID REJECTED - Adjacent Station ID Mismatch */
"Adjacent Station ID Mismatch\n", CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
__FUNCTION__); "%s(%s): Adjacent Station ID Mismatch",
CTCM_FUNTAIL, ch->id);
} }
if (xid->xid2_sender_id != grp->saved_xid2->xid2_sender_id) { if (xid->xid2_sender_id != grp->saved_xid2->xid2_sender_id) {
failed = 1; rc = 6;
printk(KERN_INFO "%s XID REJECTED - " /* XID REJECTED - Sender Address Mismatch */
"Sender Address Mismatch\n", __FUNCTION__); CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"%s(%s): Sender Address Mismatch",
CTCM_FUNTAIL, ch->id);
} }
} }
if (failed) { done:
if (rc) {
ctcm_pr_info("ctcmpc : %s() failed\n", __FUNCTION__); ctcm_pr_info("ctcmpc : %s() failed\n", __FUNCTION__);
priv->xid->xid2_flag2 = 0x40; priv->xid->xid2_flag2 = 0x40;
grp->saved_xid2->xid2_flag2 = 0x40; grp->saved_xid2->xid2_flag2 = 0x40;
rc = 1;
} }
done:
ctcm_pr_debug("ctcmpc exit: %s()\n", __FUNCTION__);
return rc; return rc;
} }
...@@ -1839,46 +1689,20 @@ static int mpc_validate_xid(struct mpcg_info *mpcginfo) ...@@ -1839,46 +1689,20 @@ static int mpc_validate_xid(struct mpcg_info *mpcginfo)
static void mpc_action_side_xid(fsm_instance *fsm, void *arg, int side) static void mpc_action_side_xid(fsm_instance *fsm, void *arg, int side)
{ {
struct channel *ch = arg; struct channel *ch = arg;
struct ctcm_priv *priv;
struct mpc_group *grp = NULL;
struct net_device *dev = NULL;
int rc = 0; int rc = 0;
int gotlock = 0; int gotlock = 0;
unsigned long saveflags = 0; /* avoids compiler warning with unsigned long saveflags = 0; /* avoids compiler warning with
spin_unlock_irqrestore */ spin_unlock_irqrestore */
if (ch == NULL) { CTCM_PR_DEBUG("Enter %s: cp=%i ch=0x%p id=%s\n",
printk(KERN_INFO "%s ch=NULL\n", __FUNCTION__); __func__, smp_processor_id(), ch, ch->id);
goto done;
}
if (do_debug)
ctcm_pr_debug("ctcmpc enter: %s(): cp=%i ch=0x%p id=%s\n",
__FUNCTION__, smp_processor_id(), ch, ch->id);
dev = ch->netdev;
if (dev == NULL) {
printk(KERN_INFO "%s dev=NULL\n", __FUNCTION__);
goto done;
}
priv = dev->priv;
if (priv == NULL) {
printk(KERN_INFO "%s priv=NULL\n", __FUNCTION__);
goto done;
}
grp = priv->mpcg;
if (grp == NULL) {
printk(KERN_INFO "%s grp=NULL\n", __FUNCTION__);
goto done;
}
if (ctcm_checkalloc_buffer(ch)) if (ctcm_checkalloc_buffer(ch))
goto done; goto done;
/* skb data-buffer referencing: */ /*
* skb data-buffer referencing:
*/
ch->trans_skb->data = ch->trans_skb_data; ch->trans_skb->data = ch->trans_skb_data;
skb_reset_tail_pointer(ch->trans_skb); skb_reset_tail_pointer(ch->trans_skb);
ch->trans_skb->len = 0; ch->trans_skb->len = 0;
...@@ -1911,22 +1735,22 @@ static void mpc_action_side_xid(fsm_instance *fsm, void *arg, int side) ...@@ -1911,22 +1735,22 @@ static void mpc_action_side_xid(fsm_instance *fsm, void *arg, int side)
ch->ccw[8].count = 0; ch->ccw[8].count = 0;
ch->ccw[8].cda = 0x00; ch->ccw[8].cda = 0x00;
if (!(ch->xid_th && ch->xid && ch->xid_id))
CTCM_DBF_TEXT_(MPC_TRACE, CTC_DBF_INFO,
"%s(%s): xid_th=%p, xid=%p, xid_id=%p",
CTCM_FUNTAIL, ch->id, ch->xid_th, ch->xid, ch->xid_id);
if (side == XSIDE) { if (side == XSIDE) {
/* mpc_action_xside_xid */ /* mpc_action_xside_xid */
if (ch->xid_th == NULL) { if (ch->xid_th == NULL)
printk(KERN_INFO "%s ch->xid_th=NULL\n", __FUNCTION__);
goto done; goto done;
}
ch->ccw[9].cmd_code = CCW_CMD_WRITE; ch->ccw[9].cmd_code = CCW_CMD_WRITE;
ch->ccw[9].flags = CCW_FLAG_SLI | CCW_FLAG_CC; ch->ccw[9].flags = CCW_FLAG_SLI | CCW_FLAG_CC;
ch->ccw[9].count = TH_HEADER_LENGTH; ch->ccw[9].count = TH_HEADER_LENGTH;
ch->ccw[9].cda = virt_to_phys(ch->xid_th); ch->ccw[9].cda = virt_to_phys(ch->xid_th);
if (ch->xid == NULL) { if (ch->xid == NULL)
printk(KERN_INFO "%s ch->xid=NULL\n", __FUNCTION__);
goto done; goto done;
}
ch->ccw[10].cmd_code = CCW_CMD_WRITE; ch->ccw[10].cmd_code = CCW_CMD_WRITE;
ch->ccw[10].flags = CCW_FLAG_SLI | CCW_FLAG_CC; ch->ccw[10].flags = CCW_FLAG_SLI | CCW_FLAG_CC;
ch->ccw[10].count = XID2_LENGTH; ch->ccw[10].count = XID2_LENGTH;
...@@ -1956,28 +1780,22 @@ static void mpc_action_side_xid(fsm_instance *fsm, void *arg, int side) ...@@ -1956,28 +1780,22 @@ static void mpc_action_side_xid(fsm_instance *fsm, void *arg, int side)
ch->ccw[10].count = XID2_LENGTH; ch->ccw[10].count = XID2_LENGTH;
ch->ccw[10].cda = virt_to_phys(ch->rcvd_xid); ch->ccw[10].cda = virt_to_phys(ch->rcvd_xid);
if (ch->xid_th == NULL) { if (ch->xid_th == NULL)
printk(KERN_INFO "%s ch->xid_th=NULL\n", __FUNCTION__);
goto done; goto done;
}
ch->ccw[11].cmd_code = CCW_CMD_WRITE; ch->ccw[11].cmd_code = CCW_CMD_WRITE;
ch->ccw[11].flags = CCW_FLAG_SLI | CCW_FLAG_CC; ch->ccw[11].flags = CCW_FLAG_SLI | CCW_FLAG_CC;
ch->ccw[11].count = TH_HEADER_LENGTH; ch->ccw[11].count = TH_HEADER_LENGTH;
ch->ccw[11].cda = virt_to_phys(ch->xid_th); ch->ccw[11].cda = virt_to_phys(ch->xid_th);
if (ch->xid == NULL) { if (ch->xid == NULL)
printk(KERN_INFO "%s ch->xid=NULL\n", __FUNCTION__);
goto done; goto done;
}
ch->ccw[12].cmd_code = CCW_CMD_WRITE; ch->ccw[12].cmd_code = CCW_CMD_WRITE;
ch->ccw[12].flags = CCW_FLAG_SLI | CCW_FLAG_CC; ch->ccw[12].flags = CCW_FLAG_SLI | CCW_FLAG_CC;
ch->ccw[12].count = XID2_LENGTH; ch->ccw[12].count = XID2_LENGTH;
ch->ccw[12].cda = virt_to_phys(ch->xid); ch->ccw[12].cda = virt_to_phys(ch->xid);
if (ch->xid_id == NULL) { if (ch->xid_id == NULL)
printk(KERN_INFO "%s ch->xid_id=NULL\n", __FUNCTION__);
goto done; goto done;
}
ch->ccw[13].cmd_code = CCW_CMD_WRITE; ch->ccw[13].cmd_code = CCW_CMD_WRITE;
ch->ccw[13].cda = virt_to_phys(ch->xid_id); ch->ccw[13].cda = virt_to_phys(ch->xid_id);
...@@ -1990,12 +1808,11 @@ static void mpc_action_side_xid(fsm_instance *fsm, void *arg, int side) ...@@ -1990,12 +1808,11 @@ static void mpc_action_side_xid(fsm_instance *fsm, void *arg, int side)
ch->ccw[14].count = 0; ch->ccw[14].count = 0;
ch->ccw[14].cda = 0; ch->ccw[14].cda = 0;
if (do_debug_ccw) CTCM_CCW_DUMP((char *)&ch->ccw[8], sizeof(struct ccw1) * 7);
ctcmpc_dumpit((char *)&ch->ccw[8], sizeof(struct ccw1) * 7); CTCM_D3_DUMP((char *)ch->xid_th, TH_HEADER_LENGTH);
CTCM_D3_DUMP((char *)ch->xid, XID2_LENGTH);
CTCM_D3_DUMP((char *)ch->xid_id, 4);
ctcmpc_dumpit((char *)ch->xid_th, TH_HEADER_LENGTH);
ctcmpc_dumpit((char *)ch->xid, XID2_LENGTH);
ctcmpc_dumpit((char *)ch->xid_id, 4);
if (!in_irq()) { if (!in_irq()) {
/* Such conditional locking is a known problem for /* Such conditional locking is a known problem for
* sparse because its static undeterministic. * sparse because its static undeterministic.
...@@ -2012,16 +1829,13 @@ static void mpc_action_side_xid(fsm_instance *fsm, void *arg, int side) ...@@ -2012,16 +1829,13 @@ static void mpc_action_side_xid(fsm_instance *fsm, void *arg, int side)
spin_unlock_irqrestore(get_ccwdev_lock(ch->cdev), saveflags); spin_unlock_irqrestore(get_ccwdev_lock(ch->cdev), saveflags);
if (rc != 0) { if (rc != 0) {
ctcm_pr_info("ctcmpc: %s() ch:%s IO failed \n",
__FUNCTION__, ch->id);
ctcm_ccw_check_rc(ch, rc, ctcm_ccw_check_rc(ch, rc,
(side == XSIDE) ? "x-side XID" : "y-side XID"); (side == XSIDE) ? "x-side XID" : "y-side XID");
} }
done: done:
if (do_debug) CTCM_PR_DEBUG("Exit %s: ch=0x%p id=%s\n",
ctcm_pr_debug("ctcmpc exit : %s(): ch=0x%p id=%s\n", __func__, ch, ch->id);
__FUNCTION__, ch, ch->id);
return; return;
} }
...@@ -2051,40 +1865,18 @@ static void mpc_action_yside_xid(fsm_instance *fsm, int event, void *arg) ...@@ -2051,40 +1865,18 @@ static void mpc_action_yside_xid(fsm_instance *fsm, int event, void *arg)
static void mpc_action_doxid0(fsm_instance *fsm, int event, void *arg) static void mpc_action_doxid0(fsm_instance *fsm, int event, void *arg)
{ {
struct channel *ch = arg; struct channel *ch = arg;
struct ctcm_priv *priv; struct net_device *dev = ch->netdev;
struct mpc_group *grp = NULL; struct ctcm_priv *priv = dev->priv;
struct net_device *dev = NULL; struct mpc_group *grp = priv->mpcg;
if (do_debug)
ctcm_pr_debug("ctcmpc enter: %s(): cp=%i ch=0x%p id=%s\n",
__FUNCTION__, smp_processor_id(), ch, ch->id);
if (ch == NULL) {
printk(KERN_WARNING "%s ch=NULL\n", __FUNCTION__);
goto done;
}
dev = ch->netdev;
if (dev == NULL) {
printk(KERN_WARNING "%s dev=NULL\n", __FUNCTION__);
goto done;
}
priv = dev->priv;
if (priv == NULL) {
printk(KERN_WARNING "%s priv=NULL\n", __FUNCTION__);
goto done;
}
grp = priv->mpcg; CTCM_PR_DEBUG("Enter %s: cp=%i ch=0x%p id=%s\n",
if (grp == NULL) { __func__, smp_processor_id(), ch, ch->id);
printk(KERN_WARNING "%s grp=NULL\n", __FUNCTION__);
goto done;
}
if (ch->xid == NULL) { if (ch->xid == NULL) {
printk(KERN_WARNING "%s ch-xid=NULL\n", __FUNCTION__); CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
goto done; "%s(%s): ch->xid == NULL",
CTCM_FUNTAIL, dev->name);
return;
} }
fsm_newstate(ch->fsm, CH_XID0_INPROGRESS); fsm_newstate(ch->fsm, CH_XID0_INPROGRESS);
...@@ -2104,12 +1896,7 @@ static void mpc_action_doxid0(fsm_instance *fsm, int event, void *arg) ...@@ -2104,12 +1896,7 @@ static void mpc_action_doxid0(fsm_instance *fsm, int event, void *arg)
fsm_event(grp->fsm, MPCG_EVENT_DOIO, ch); fsm_event(grp->fsm, MPCG_EVENT_DOIO, ch);
done:
if (do_debug)
ctcm_pr_debug("ctcmpc exit : %s(): ch=0x%p id=%s\n",
__FUNCTION__, ch, ch->id);
return; return;
} }
/* /*
...@@ -2119,32 +1906,16 @@ static void mpc_action_doxid0(fsm_instance *fsm, int event, void *arg) ...@@ -2119,32 +1906,16 @@ static void mpc_action_doxid0(fsm_instance *fsm, int event, void *arg)
static void mpc_action_doxid7(fsm_instance *fsm, int event, void *arg) static void mpc_action_doxid7(fsm_instance *fsm, int event, void *arg)
{ {
struct net_device *dev = arg; struct net_device *dev = arg;
struct ctcm_priv *priv = NULL; struct ctcm_priv *priv = dev->priv;
struct mpc_group *grp = NULL; struct mpc_group *grp = NULL;
int direction; int direction;
int rc = 0;
int send = 0; int send = 0;
ctcm_pr_debug("ctcmpc enter: %s() \n", __FUNCTION__); if (priv)
if (dev == NULL) {
printk(KERN_INFO "%s dev=NULL \n", __FUNCTION__);
rc = 1;
goto done;
}
priv = dev->priv;
if (priv == NULL) {
printk(KERN_INFO "%s priv=NULL \n", __FUNCTION__);
rc = 1;
goto done;
}
grp = priv->mpcg; grp = priv->mpcg;
if (grp == NULL) { if (grp == NULL) {
printk(KERN_INFO "%s grp=NULL \n", __FUNCTION__); fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
rc = 1; return;
goto done;
} }
for (direction = READ; direction <= WRITE; direction++) { for (direction = READ; direction <= WRITE; direction++) {
...@@ -2199,11 +1970,6 @@ static void mpc_action_doxid7(fsm_instance *fsm, int event, void *arg) ...@@ -2199,11 +1970,6 @@ static void mpc_action_doxid7(fsm_instance *fsm, int event, void *arg)
fsm_event(grp->fsm, MPCG_EVENT_DOIO, ch); fsm_event(grp->fsm, MPCG_EVENT_DOIO, ch);
} }
done:
if (rc != 0)
fsm_event(grp->fsm, MPCG_EVENT_INOP, dev);
return; return;
} }
...@@ -2217,21 +1983,12 @@ static void mpc_action_rcvd_xid0(fsm_instance *fsm, int event, void *arg) ...@@ -2217,21 +1983,12 @@ static void mpc_action_rcvd_xid0(fsm_instance *fsm, int event, void *arg)
struct mpcg_info *mpcginfo = arg; struct mpcg_info *mpcginfo = arg;
struct channel *ch = mpcginfo->ch; struct channel *ch = mpcginfo->ch;
struct net_device *dev = ch->netdev; struct net_device *dev = ch->netdev;
struct ctcm_priv *priv; struct ctcm_priv *priv = dev->priv;
struct mpc_group *grp; struct mpc_group *grp = priv->mpcg;
if (do_debug)
ctcm_pr_debug("ctcmpc enter: %s(): cp=%i ch=0x%p id=%s\n",
__FUNCTION__, smp_processor_id(), ch, ch->id);
priv = dev->priv;
grp = priv->mpcg;
ctcm_pr_debug("ctcmpc in:%s() %s xid2:%i xid7:%i xidt_p2:%i \n", CTCM_PR_DEBUG("%s: ch-id:%s xid2:%i xid7:%i xidt_p2:%i \n",
__FUNCTION__, ch->id, __func__, ch->id, grp->outstanding_xid2,
grp->outstanding_xid2, grp->outstanding_xid7, grp->outstanding_xid7_p2);
grp->outstanding_xid7,
grp->outstanding_xid7_p2);
if (fsm_getstate(ch->fsm) < CH_XID7_PENDING) if (fsm_getstate(ch->fsm) < CH_XID7_PENDING)
fsm_newstate(ch->fsm, CH_XID7_PENDING); fsm_newstate(ch->fsm, CH_XID7_PENDING);
...@@ -2268,17 +2025,12 @@ static void mpc_action_rcvd_xid0(fsm_instance *fsm, int event, void *arg) ...@@ -2268,17 +2025,12 @@ static void mpc_action_rcvd_xid0(fsm_instance *fsm, int event, void *arg)
} }
kfree(mpcginfo); kfree(mpcginfo);
if (do_debug) { CTCM_PR_DEBUG("ctcmpc:%s() %s xid2:%i xid7:%i xidt_p2:%i \n",
ctcm_pr_debug("ctcmpc:%s() %s xid2:%i xid7:%i xidt_p2:%i \n", __func__, ch->id, grp->outstanding_xid2,
__FUNCTION__, ch->id, grp->outstanding_xid7, grp->outstanding_xid7_p2);
grp->outstanding_xid2, CTCM_PR_DEBUG("ctcmpc:%s() %s grpstate: %s chanstate: %s \n",
grp->outstanding_xid7, __func__, ch->id,
grp->outstanding_xid7_p2); fsm_getstate_str(grp->fsm), fsm_getstate_str(ch->fsm));
ctcm_pr_debug("ctcmpc:%s() %s grpstate: %s chanstate: %s \n",
__FUNCTION__, ch->id,
fsm_getstate_str(grp->fsm),
fsm_getstate_str(ch->fsm));
}
return; return;
} }
...@@ -2296,15 +2048,10 @@ static void mpc_action_rcvd_xid7(fsm_instance *fsm, int event, void *arg) ...@@ -2296,15 +2048,10 @@ static void mpc_action_rcvd_xid7(fsm_instance *fsm, int event, void *arg)
struct ctcm_priv *priv = dev->priv; struct ctcm_priv *priv = dev->priv;
struct mpc_group *grp = priv->mpcg; struct mpc_group *grp = priv->mpcg;
if (do_debug) { CTCM_PR_DEBUG("Enter %s: cp=%i ch=0x%p id=%s\n",
ctcm_pr_debug("ctcmpc enter: %s(): cp=%i ch=0x%p id=%s\n", __func__, smp_processor_id(), ch, ch->id);
__FUNCTION__, smp_processor_id(), ch, ch->id); CTCM_PR_DEBUG("%s: outstanding_xid7: %i, outstanding_xid7_p2: %i\n",
__func__, grp->outstanding_xid7, grp->outstanding_xid7_p2);
ctcm_pr_debug("ctcmpc: outstanding_xid7: %i, "
" outstanding_xid7_p2: %i\n",
grp->outstanding_xid7,
grp->outstanding_xid7_p2);
}
grp->outstanding_xid7--; grp->outstanding_xid7--;
ch->xid_skb->data = ch->xid_skb_data; ch->xid_skb->data = ch->xid_skb_data;
...@@ -2337,14 +2084,8 @@ static void mpc_action_rcvd_xid7(fsm_instance *fsm, int event, void *arg) ...@@ -2337,14 +2084,8 @@ static void mpc_action_rcvd_xid7(fsm_instance *fsm, int event, void *arg)
mpc_validate_xid(mpcginfo); mpc_validate_xid(mpcginfo);
break; break;
} }
kfree(mpcginfo); kfree(mpcginfo);
if (do_debug)
ctcm_pr_debug("ctcmpc exit: %s(): cp=%i ch=0x%p id=%s\n",
__FUNCTION__, smp_processor_id(), ch, ch->id);
return; return;
} }
/* /*
...@@ -2353,36 +2094,14 @@ static void mpc_action_rcvd_xid7(fsm_instance *fsm, int event, void *arg) ...@@ -2353,36 +2094,14 @@ static void mpc_action_rcvd_xid7(fsm_instance *fsm, int event, void *arg)
*/ */
static int mpc_send_qllc_discontact(struct net_device *dev) static int mpc_send_qllc_discontact(struct net_device *dev)
{ {
int rc = 0;
__u32 new_len = 0; __u32 new_len = 0;
struct sk_buff *skb; struct sk_buff *skb;
struct qllc *qllcptr; struct qllc *qllcptr;
struct ctcm_priv *priv; struct ctcm_priv *priv = dev->priv;
struct mpc_group *grp; struct mpc_group *grp = priv->mpcg;
ctcm_pr_debug("ctcmpc enter: %s()\n", __FUNCTION__);
if (dev == NULL) {
printk(KERN_INFO "%s() dev=NULL\n", __FUNCTION__);
rc = 1;
goto done;
}
priv = dev->priv; CTCM_PR_DEBUG("%s: GROUP STATE: %s\n",
if (priv == NULL) { __func__, mpcg_state_names[grp->saved_state]);
printk(KERN_INFO "%s() priv=NULL\n", __FUNCTION__);
rc = 1;
goto done;
}
grp = priv->mpcg;
if (grp == NULL) {
printk(KERN_INFO "%s() grp=NULL\n", __FUNCTION__);
rc = 1;
goto done;
}
ctcm_pr_info("ctcmpc: %s() GROUP STATE: %s\n", __FUNCTION__,
mpcg_state_names[grp->saved_state]);
switch (grp->saved_state) { switch (grp->saved_state) {
/* /*
...@@ -2408,11 +2127,10 @@ static int mpc_send_qllc_discontact(struct net_device *dev) ...@@ -2408,11 +2127,10 @@ static int mpc_send_qllc_discontact(struct net_device *dev)
new_len = sizeof(struct qllc); new_len = sizeof(struct qllc);
qllcptr = kzalloc(new_len, gfp_type() | GFP_DMA); qllcptr = kzalloc(new_len, gfp_type() | GFP_DMA);
if (qllcptr == NULL) { if (qllcptr == NULL) {
printk(KERN_INFO CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
"ctcmpc: Out of memory in %s()\n", "%s(%s): qllcptr allocation error",
dev->name); CTCM_FUNTAIL, dev->name);
rc = 1; return -ENOMEM;
goto done;
} }
qllcptr->qllc_address = 0xcc; qllcptr->qllc_address = 0xcc;
...@@ -2421,31 +2139,29 @@ static int mpc_send_qllc_discontact(struct net_device *dev) ...@@ -2421,31 +2139,29 @@ static int mpc_send_qllc_discontact(struct net_device *dev)
skb = __dev_alloc_skb(new_len, GFP_ATOMIC); skb = __dev_alloc_skb(new_len, GFP_ATOMIC);
if (skb == NULL) { if (skb == NULL) {
printk(KERN_INFO "%s Out of memory in mpc_send_qllc\n", CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
dev->name); "%s(%s): skb allocation error",
CTCM_FUNTAIL, dev->name);
priv->stats.rx_dropped++; priv->stats.rx_dropped++;
rc = 1;
kfree(qllcptr); kfree(qllcptr);
goto done; return -ENOMEM;
} }
memcpy(skb_put(skb, new_len), qllcptr, new_len); memcpy(skb_put(skb, new_len), qllcptr, new_len);
kfree(qllcptr); kfree(qllcptr);
if (skb_headroom(skb) < 4) { if (skb_headroom(skb) < 4) {
printk(KERN_INFO "ctcmpc: %s() Unable to" CTCM_DBF_TEXT_(MPC_ERROR, CTC_DBF_ERROR,
" build discontact for %s\n", "%s(%s): skb_headroom error",
__FUNCTION__, dev->name); CTCM_FUNTAIL, dev->name);
rc = 1;
dev_kfree_skb_any(skb); dev_kfree_skb_any(skb);
goto done; return -ENOMEM;
} }
*((__u32 *)skb_push(skb, 4)) = priv->channel[READ]->pdu_seq; *((__u32 *)skb_push(skb, 4)) = priv->channel[READ]->pdu_seq;
priv->channel[READ]->pdu_seq++; priv->channel[READ]->pdu_seq++;
if (do_debug_data) CTCM_PR_DBGDATA("ctcmpc: %s ToDCM_pdu_seq= %08x\n",
ctcm_pr_debug("ctcmpc: %s ToDCM_pdu_seq= %08x\n", __func__, priv->channel[READ]->pdu_seq);
__FUNCTION__, priv->channel[READ]->pdu_seq);
/* receipt of CC03 resets anticipated sequence number on /* receipt of CC03 resets anticipated sequence number on
receiving side */ receiving side */
...@@ -2455,7 +2171,7 @@ static int mpc_send_qllc_discontact(struct net_device *dev) ...@@ -2455,7 +2171,7 @@ static int mpc_send_qllc_discontact(struct net_device *dev)
skb->protocol = htons(ETH_P_SNAP); skb->protocol = htons(ETH_P_SNAP);
skb->ip_summed = CHECKSUM_UNNECESSARY; skb->ip_summed = CHECKSUM_UNNECESSARY;
ctcmpc_dumpit((char *)skb->data, (sizeof(struct qllc) + 4)); CTCM_D3_DUMP(skb->data, (sizeof(struct qllc) + 4));
netif_rx(skb); netif_rx(skb);
break; break;
...@@ -2464,9 +2180,7 @@ static int mpc_send_qllc_discontact(struct net_device *dev) ...@@ -2464,9 +2180,7 @@ static int mpc_send_qllc_discontact(struct net_device *dev)
} }
done: return 0;
ctcm_pr_debug("ctcmpc exit: %s()\n", __FUNCTION__);
return rc;
} }
/* --- This is the END my friend --- */ /* --- This is the END my friend --- */
...@@ -231,7 +231,7 @@ static inline void ctcmpc_dump32(char *buf, int len) ...@@ -231,7 +231,7 @@ static inline void ctcmpc_dump32(char *buf, int len)
int ctcmpc_open(struct net_device *); int ctcmpc_open(struct net_device *);
void ctcm_ccw_check_rc(struct channel *, int, char *); void ctcm_ccw_check_rc(struct channel *, int, char *);
void mpc_group_ready(unsigned long adev); void mpc_group_ready(unsigned long adev);
int mpc_channel_action(struct channel *ch, int direction, int action); void mpc_channel_action(struct channel *ch, int direction, int action);
void mpc_action_send_discontact(unsigned long thischan); void mpc_action_send_discontact(unsigned long thischan);
void mpc_action_discontact(fsm_instance *fi, int event, void *arg); void mpc_action_discontact(fsm_instance *fi, int event, void *arg);
void ctcmpc_bh(unsigned long thischan); void ctcmpc_bh(unsigned long thischan);
......
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