9 #define KMSG_COMPONENT "qeth"
10 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
12 #include <linux/module.h>
14 #include <linux/string.h>
15 #include <linux/errno.h>
16 #include <linux/kernel.h>
18 #include <linux/tcp.h>
19 #include <linux/mii.h>
21 #include <linux/slab.h>
26 #include <asm/sysinfo.h>
27 #include <asm/compat.h>
47 static struct kmem_cache *qeth_qdio_outbuf_cache;
49 static struct device *qeth_core_root_dev;
52 static struct mutex qeth_mod_mutex;
54 static void qeth_send_control_data_cb(
struct qeth_channel *,
56 static int qeth_issue_next_read(
struct qeth_card *);
59 static void qeth_free_buffer_pool(
struct qeth_card *);
60 static int qeth_qdio_establish(
struct qeth_card *);
61 static void qeth_free_qdio_buffers(
struct qeth_card *);
71 static inline const char *qeth_get_cardname(
struct qeth_card *
card)
73 if (card->
info.guestlan) {
74 switch (card->
info.type) {
76 return " Guest LAN QDIO";
78 return " Guest LAN Hiper";
80 return " Guest LAN QDIO - OSM";
82 return " Guest LAN QDIO - OSX";
87 switch (card->
info.type) {
89 return " OSD Express";
91 return " HiperSockets";
108 if (card->
info.guestlan) {
109 switch (card->
info.type) {
111 return "GuestLAN QDIO";
113 return "GuestLAN Hiper";
115 return "GuestLAN OSM";
117 return "GuestLAN OSX";
122 switch (card->
info.type) {
124 switch (card->
info.link_type) {
134 return "OSD_FE_LANE";
136 return "OSD_TR_LANE";
138 return "OSD_GbE_LANE";
140 return "OSD_ATM_LANE";
142 return "OSD_Express";
145 return "HiperSockets";
160 int clear_start_mask)
166 if (clear_start_mask)
198 &card->
qdio.in_buf_pool.entry_list,
list){
204 static int qeth_alloc_buffer_pool(
struct qeth_card *card)
211 for (i = 0; i < card->
qdio.init_pool.buf_count; ++
i) {
212 pool_entry = kzalloc(
sizeof(*pool_entry),
GFP_KERNEL);
214 qeth_free_buffer_pool(card);
224 qeth_free_buffer_pool(card);
230 &card->
qdio.init_pool.entry_list);
245 qeth_free_buffer_pool(card);
246 card->
qdio.in_buf_pool.buf_count = bufcnt;
247 card->
qdio.init_pool.buf_count = bufcnt;
248 return qeth_alloc_buffer_pool(card);
252 static inline int qeth_cq_init(
struct qeth_card *card)
260 card->
qdio.c_q->next_buf_to_init = 127;
262 card->
qdio.no_in_queues - 1, 0,
274 static inline int qeth_alloc_cq(
struct qeth_card *card)
285 if (!card->
qdio.c_q) {
292 card->
qdio.c_q->bufs[
i].buffer =
293 &card->
qdio.c_q->qdio_bufs[
i];
296 card->
qdio.no_in_queues = 2;
299 kzalloc(card->
qdio.no_out_queues *
300 QDIO_MAX_BUFFERS_PER_Q *
302 outbuf_states = card->
qdio.out_bufstates;
303 if (outbuf_states ==
NULL) {
307 for (i = 0; i < card->
qdio.no_out_queues; ++
i) {
308 card->
qdio.out_qs[
i]->bufstates = outbuf_states;
314 card->
qdio.no_in_queues = 1;
324 dev_err(&card->
gdev->dev,
"Failed to create completion queue\n");
328 static inline void qeth_free_cq(
struct qeth_card *card)
330 if (card->
qdio.c_q) {
331 --card->
qdio.no_in_queues;
339 static inline enum iucv_tx_notify qeth_compute_cq_notification(
int sbalf15,
364 int bidx,
int forced_cleanup)
369 if (q->
bufs[bidx]->next_pending !=
NULL) {
374 if (forced_cleanup ||
383 qeth_release_skbs(c);
400 qeth_init_qdio_out_buf(q, bidx);
406 static inline void qeth_qdio_handle_aob(
struct qeth_card *card,
407 unsigned long phys_aob_addr) {
429 if (aob->
aorc != 0) {
431 notification = qeth_compute_cq_notification(aob->
aorc, 1);
433 qeth_notify_skbs(buffer->
q, buffer, notification);
436 qeth_clear_output_buffer(buffer->
q, buffer,
443 static inline int qeth_is_cq(
struct qeth_card *card,
unsigned int queue)
448 queue == card->
qdio.no_in_queues - 1;
452 static int qeth_issue_next_read(
struct qeth_card *card)
460 iob = qeth_get_buffer(&card->
read);
463 "failed to recover an error on the device\n");
465 "available\n", dev_name(&card->
gdev->dev));
474 "rc=%i\n", dev_name(&card->
gdev->dev), rc);
496 static void qeth_get_reply(
struct qeth_reply *reply)
502 static void qeth_put_reply(
struct qeth_reply *reply)
513 int com = cmd->
hdr.command;
518 ipa_name, com, dev_name(&card->
gdev->dev),
523 ipa_name, com, dev_name(&card->
gdev->dev),
540 qeth_issue_ipa_msg(cmd,
541 cmd->
hdr.return_code, card);
544 switch (cmd->
hdr.command) {
547 "The link for interface %s on CHPID"
552 if (card->
dev && netif_carrier_ok(card->
dev))
557 "The link for %s on CHPID 0x%X has"
563 if (card->
info.hwtrap)
564 card->
info.hwtrap = 2;
577 "but not a reply!\n");
594 qeth_get_reply(reply);
597 list_del_init(&reply->
list);
599 qeth_put_reply(reply);
601 spin_unlock_irqrestore(&card->
lock, flags);
606 static int qeth_check_idx_response(
struct qeth_card *card,
607 unsigned char *buffer)
613 if ((buffer[2] & 0xc0) == 0xc0) {
615 "with cause code 0x%02x%s\n",
617 ((buffer[4] == 0x22) ?
618 " -- try another portname" :
""));
622 if (buffer[4] == 0xf6) {
624 "The qeth device is not configured "
625 "for the OSI layer required by z/VM\n");
638 card = CARD_FROM_CDEV(channel->
ccwdev);
640 if (channel == &card->
read)
644 channel->
ccw.count = len;
677 iob->
callback = qeth_send_control_data_cb;
679 spin_unlock_irqrestore(&channel->
iob_lock, flags);
690 buffer = __qeth_get_buffer(channel);
691 spin_unlock_irqrestore(&channel->
iob_lock, flags);
699 ((buffer = qeth_get_buffer(channel)) !=
NULL));
715 static void qeth_send_control_data_cb(
struct qeth_channel *channel,
725 card = CARD_FROM_CDEV(channel->
ccwdev);
727 rc = qeth_check_idx_response(card, iob->
data);
739 cmd = qeth_check_ipa_data(card, iob);
754 ((cmd) && (reply->
seqno == cmd->
hdr.seqno))) {
755 qeth_get_reply(reply);
756 list_del_init(&reply->
list);
757 spin_unlock_irqrestore(&card->
lock, flags);
772 reply->
rc = (
u16) cmd->
hdr.return_code;
779 spin_unlock_irqrestore(&card->
lock, flags);
784 qeth_put_reply(reply);
788 spin_unlock_irqrestore(&card->
lock, flags);
796 static int qeth_setup_channel(
struct qeth_channel *channel)
804 if (channel->
iob[cnt].data ==
NULL)
808 channel->
iob[
cnt].callback = qeth_send_control_data_cb;
811 if (cnt < QETH_CMD_BUFFER_NO) {
825 static int qeth_set_thread_start_bit(
struct qeth_card *card,
863 static int __qeth_do_run_thread(
struct qeth_card *card,
unsigned long thread)
887 (rc = __qeth_do_run_thread(card, thread)) >= 0);
906 sense = (
char *) irb->
ecw;
909 card = CARD_FROM_CDEV(cdev);
916 "failed to recover an error on the device\n");
918 dev_name(&cdev->
dev), dstat, cstat);
935 if ((sense[2] == 0xaf) && (sense[3] == 0xfe)) {
939 if ((!sense[0]) && (!sense[1]) && (!sense[2]) && (!sense[3])) {
949 static long __qeth_check_irb_error(
struct ccw_device *cdev,
950 unsigned long intparm,
struct irb *irb)
954 card = CARD_FROM_CDEV(cdev);
959 switch (PTR_ERR(irb)) {
962 dev_name(&cdev->
dev));
967 dev_warn(&cdev->
dev,
"A hardware operation timed out"
972 if (card && (card->
data.ccwdev == cdev)) {
980 dev_name(&cdev->
dev), PTR_ERR(irb));
987 static void qeth_irq(
struct ccw_device *cdev,
unsigned long intparm,
998 if (__qeth_check_irb_error(cdev, intparm, irb))
1003 card = CARD_FROM_CDEV(cdev);
1009 if (card->
read.ccwdev == cdev) {
1010 channel = &card->
read;
1012 }
else if (card->
write.ccwdev == cdev) {
1013 channel = &card->
write;
1016 channel = &card->
data;
1028 if ((channel == &card->
data) && (intparm != 0) &&
1043 (dstat & DEV_STAT_UNIT_CHECK) ||
1047 "The qeth device driver failed to recover "
1048 "an error on the device\n");
1050 "0x%X dstat 0x%X\n",
1051 dev_name(&channel->
ccwdev->dev), cstat, dstat);
1061 rc = qeth_get_problem(cdev, irb);
1077 if (channel == &card->
data)
1079 if (channel == &card->
read &&
1081 qeth_issue_next_read(card);
1089 index = (index + 1) % QETH_CMD_BUFFER_NO;
1103 if (skb_queue_empty(&buf->
skb_list))
1115 if (skb_queue_is_last(&buf->
skb_list, skb))
1118 skb = skb_queue_next(&buf->
skb_list, skb);
1128 int notify_general_error = 0;
1131 notify_general_error = 1;
1163 qeth_release_skbs(buf);
1168 buf->
buffer->element[i].addr);
1170 buf->
buffer->element[
i].length = 0;
1172 buf->
buffer->element[
i].eflags = 0;
1173 buf->
buffer->element[
i].sflags = 0;
1175 buf->
buffer->element[15].eflags = 0;
1176 buf->
buffer->element[15].sflags = 0;
1188 qeth_cleanup_handled_pending(q, j, 1);
1203 for (i = 0; i < card->
qdio.no_out_queues; ++
i) {
1204 if (card->
qdio.out_qs[i]) {
1205 qeth_clear_outq_buffers(card->
qdio.out_qs[i], 0);
1211 static void qeth_free_buffer_pool(
struct qeth_card *card)
1224 static void qeth_free_qdio_buffers(
struct qeth_card *card)
1239 qeth_free_buffer_pool(card);
1241 if (card->
qdio.out_qs) {
1242 for (i = 0; i < card->
qdio.no_out_queues; ++
i) {
1243 qeth_clear_outq_buffers(card->
qdio.out_qs[i], 1);
1251 static void qeth_clean_channel(
struct qeth_channel *channel)
1260 static void qeth_set_single_write_queues(
struct qeth_card *card)
1263 (card->
qdio.no_out_queues == 4))
1264 qeth_free_qdio_buffers(card);
1266 card->
qdio.no_out_queues = 1;
1267 if (card->
qdio.default_out_queue != 0)
1268 dev_info(&card->
gdev->dev,
"Priority Queueing not supported\n");
1270 card->
qdio.default_out_queue = 0;
1273 static void qeth_set_multiple_write_queues(
struct qeth_card *card)
1276 (card->
qdio.no_out_queues == 1)) {
1277 qeth_free_qdio_buffers(card);
1278 card->
qdio.default_out_queue = 2;
1280 card->
qdio.no_out_queues = 4;
1283 static void qeth_update_from_chp_desc(
struct qeth_card *card)
1286 struct channelPath_dsc {
1299 ccwdev = card->
data.ccwdev;
1304 card->
info.func_level = 0x4100 + chp_dsc->desc;
1309 if ((chp_dsc->chpp & 0x02) == 0x02)
1310 qeth_set_single_write_queues(card);
1312 qeth_set_multiple_write_queues(card);
1319 static void qeth_init_qdio_info(
struct qeth_card *card)
1329 card->
qdio.in_buf_pool.buf_count = card->
qdio.init_pool.buf_count;
1330 INIT_LIST_HEAD(&card->
qdio.in_buf_pool.entry_list);
1331 INIT_LIST_HEAD(&card->
qdio.init_pool.entry_list);
1334 static void qeth_set_intial_options(
struct qeth_card *card)
1338 card->
options.fake_broadcast = 0;
1340 card->
options.performance_stats = 0;
1346 static int qeth_do_start_thread(
struct qeth_card *card,
unsigned long thread)
1348 unsigned long flags;
1382 static int qeth_setup_card(
struct qeth_card *card)
1406 INIT_LIST_HEAD(&card->
ip_list);
1411 qeth_set_intial_options(card);
1413 INIT_LIST_HEAD(&card->
ipato.entries);
1414 card->
ipato.enabled = 0;
1415 card->
ipato.invert4 = 0;
1416 card->
ipato.invert6 = 0;
1418 qeth_init_qdio_info(card);
1427 if (card->
info.mcl_level[0])
1428 seq_printf(m,
"qeth: %s firmware level %s\n",
1432 static struct qeth_card *qeth_alloc_card(
void)
1446 if (qeth_setup_channel(&card->
read))
1448 if (qeth_setup_channel(&card->
write))
1456 qeth_clean_channel(&card->
read);
1465 static int qeth_determine_card_type(
struct qeth_card *card)
1477 known_devices[i][QETH_DEV_MODEL_IND])) {
1479 card->
qdio.no_out_queues =
1481 card->
qdio.no_in_queues = 1;
1482 card->
info.is_multicast_different =
1484 qeth_update_from_chp_desc(card);
1490 dev_err(&card->
gdev->dev,
"The adapter hardware is of an "
1495 static int qeth_clear_channel(
struct qeth_channel *channel)
1497 unsigned long flags;
1501 card = CARD_FROM_CDEV(channel->
ccwdev);
1519 static int qeth_halt_channel(
struct qeth_channel *channel)
1521 unsigned long flags;
1525 card = CARD_FROM_CDEV(channel->
ccwdev);
1542 static int qeth_halt_channels(
struct qeth_card *card)
1544 int rc1 = 0, rc2 = 0, rc3 = 0;
1547 rc1 = qeth_halt_channel(&card->
read);
1548 rc2 = qeth_halt_channel(&card->
write);
1549 rc3 = qeth_halt_channel(&card->
data);
1557 static int qeth_clear_channels(
struct qeth_card *card)
1559 int rc1 = 0, rc2 = 0, rc3 = 0;
1562 rc1 = qeth_clear_channel(&card->
read);
1563 rc2 = qeth_clear_channel(&card->
write);
1564 rc3 = qeth_clear_channel(&card->
data);
1572 static int qeth_clear_halt_card(
struct qeth_card *card,
int halt)
1579 rc = qeth_halt_channels(card);
1582 return qeth_clear_channels(card);
1609 rc = qeth_clear_halt_card(card, use_halt);
1617 static int qeth_read_conf_data(
struct qeth_card *card,
void **buffer,
1624 unsigned long flags;
1630 if (!ciw || ciw->
cmd == 0)
1636 channel->
ccw.cmd_code = ciw->
cmd;
1659 *length = ciw->
count;
1665 static void qeth_configure_unitaddr(
struct qeth_card *card,
char *prcd)
1668 card->
info.chpid = prcd[30];
1669 card->
info.unit_addr2 = prcd[31];
1670 card->
info.cula = prcd[63];
1671 card->
info.guestlan = ((prcd[0x10] ==
_ascebc[
'V']) &&
1672 (prcd[0x11] ==
_ascebc[
'M']));
1675 static void qeth_configure_blkt_default(
struct qeth_card *card,
char *prcd)
1679 if (prcd[74] == 0xF0 && prcd[75] == 0xF0 &&
1680 (prcd[76] == 0xF5 || prcd[76] == 0xF6)) {
1681 card->
info.blkt.time_total = 250;
1682 card->
info.blkt.inter_packet = 5;
1683 card->
info.blkt.inter_packet_jumbo = 15;
1685 card->
info.blkt.time_total = 0;
1686 card->
info.blkt.inter_packet = 0;
1687 card->
info.blkt.inter_packet_jumbo = 0;
1691 static void qeth_init_tokens(
struct qeth_card *card)
1693 card->
token.issuer_rm_w = 0x00010103
UL;
1694 card->
token.cm_filter_w = 0x00010108
UL;
1695 card->
token.cm_connection_w = 0x0001010a
UL;
1696 card->
token.ulp_filter_w = 0x0001010b
UL;
1697 card->
token.ulp_connection_w = 0x0001010d
UL;
1700 static void qeth_init_func_level(
struct qeth_card *card)
1702 switch (card->
info.type) {
1715 static int qeth_idx_activate_get_answer(
struct qeth_channel *channel,
1720 unsigned long flags;
1725 card = CARD_FROM_CDEV(channel->
ccwdev);
1726 iob = qeth_get_buffer(channel);
1760 static int qeth_idx_activate_channel(
struct qeth_channel *channel,
1766 unsigned long flags;
1772 card = CARD_FROM_CDEV(channel->
ccwdev);
1776 iob = qeth_get_buffer(channel);
1781 if (channel == &card->write) {
1785 card->seqno.trans_hdr++;
1791 tmp = ((
__u8)card->info.portno) | 0x80;
1796 &card->info.func_level,
sizeof(
__u16));
1799 temp = (card->info.cula << 8) + card->info.unit_addr2;
1824 " failed to recover an error on the device\n");
1826 dev_name(&channel->
ccwdev->dev));
1831 return qeth_idx_activate_get_answer(channel, idx_reply_cb);
1834 static int qeth_peer_func_level(
int level)
1836 if ((level & 0xff) == 8)
1837 return (level & 0xff) + 0x400;
1838 if (((level >> 8) & 3) == 1)
1839 return (level & 0xff) + 0x200;
1843 static void qeth_idx_write_cb(
struct qeth_channel *channel,
1855 card = CARD_FROM_CDEV(channel->
ccwdev);
1860 "The adapter is used exclusively by another "
1864 " negative reply\n",
1865 dev_name(&card->
write.ccwdev->dev));
1869 if ((temp & ~0x0100) != qeth_peer_func_level(card->
info.func_level)) {
1871 "function level mismatch (sent: 0x%x, received: "
1872 "0x%x)\n", dev_name(&card->
write.ccwdev->dev),
1873 card->
info.func_level, temp);
1881 static void qeth_idx_read_cb(
struct qeth_channel *channel,
1893 card = CARD_FROM_CDEV(channel->
ccwdev);
1894 if (qeth_check_idx_response(card, iob->
data))
1901 "The adapter is used exclusively by another "
1907 "Setting the device online failed because of "
1908 "insufficient authorization\n");
1912 " negative reply\n",
1913 dev_name(&card->
read.ccwdev->dev));
1926 card->
info.portname_required = 1;
1929 if (temp != qeth_peer_func_level(card->
info.func_level)) {
1931 "level mismatch (sent: 0x%x, received: 0x%x)\n",
1932 dev_name(&card->
read.ccwdev->dev),
1933 card->
info.func_level, temp);
1949 qeth_setup_ccw(&card->
write, iob->
data, len);
1954 card->
seqno.trans_hdr++;
1957 card->
seqno.pdu_hdr++;
1971 unsigned long flags;
1973 unsigned long timeout, event_timeout;
1982 reply = qeth_alloc_reply(card);
1987 reply->
param = reply_param;
1995 spin_unlock_irqrestore(&card->
lock, flags);
2005 timeout =
jiffies + event_timeout;
2014 "ccw_device_start rc = %i\n",
2015 dev_name(&card->
write.ccwdev->dev), rc);
2018 list_del_init(&reply->
list);
2019 qeth_put_reply(reply);
2020 spin_unlock_irqrestore(&card->
lock, flags);
2043 if (reply->
rc == -
EIO)
2046 qeth_put_reply(reply);
2052 list_del_init(&reply->
list);
2053 spin_unlock_irqrestore(&reply->
card->lock, flags);
2058 card->
write.buf_no = (card->
write.buf_no + 1) % QETH_CMD_BUFFER_NO;
2060 qeth_put_reply(reply);
2080 static int qeth_cm_enable(
struct qeth_card *card)
2095 qeth_cm_enable_cb,
NULL);
2115 static int qeth_cm_setup(
struct qeth_card *card)
2131 qeth_cm_setup_cb,
NULL);
2136 static inline int qeth_get_initial_mtu_for_card(
struct qeth_card *card)
2138 switch (card->
info.type) {
2142 return card->
info.max_mtu;
2144 switch (card->
info.link_type) {
2159 static inline int qeth_get_mtu_outof_framesize(
int framesize)
2161 switch (framesize) {
2175 static inline int qeth_mtu_is_valid(
struct qeth_card *card,
int mtu)
2177 switch (card->
info.type) {
2182 return ((mtu >= 576) &&
2183 (mtu <= card->
info.max_mtu));
2195 __u16 mtu, framesize;
2208 mtu = qeth_get_mtu_outof_framesize(framesize);
2214 if (card->
info.initial_mtu && (card->
info.initial_mtu != mtu)) {
2217 ((card->
dev->mtu == card->
info.initial_mtu) ||
2218 (card->
dev->mtu > mtu)))
2219 card->
dev->mtu = mtu;
2220 qeth_free_qdio_buffers(card);
2222 card->
info.initial_mtu = mtu;
2223 card->
info.max_mtu = mtu;
2226 card->
info.initial_mtu = qeth_get_initial_mtu_for_card(card);
2236 card->
info.link_type = link_type;
2238 card->
info.link_type = 0;
2244 static int qeth_ulp_enable(
struct qeth_card *card)
2272 card->
info.portname, 9);
2274 qeth_ulp_enable_cb,
NULL);
2294 dev_err(&card->
gdev->dev,
"A connection could not be "
2295 "established because of an OLM limit\n");
2302 static int qeth_ulp_setup(
struct qeth_card *card)
2323 temp = (card->
info.cula << 8) + card->
info.unit_addr2;
2326 qeth_ulp_setup_cb,
NULL);
2330 static int qeth_init_qdio_out_buf(
struct qeth_qdio_out_q *q,
int bidx)
2336 newbuf = kmem_cache_zalloc(qeth_qdio_outbuf_cache,
GFP_ATOMIC);
2342 skb_queue_head_init(&newbuf->
skb_list);
2348 q->
bufs[bidx] = newbuf;
2361 static int qeth_alloc_qdio_buffers(
struct qeth_card *card)
2373 if (!card->
qdio.in_q)
2380 card->
qdio.in_q->bufs[
i].buffer =
2381 &card->
qdio.in_q->qdio_bufs[
i];
2385 if (qeth_alloc_buffer_pool(card))
2390 kzalloc(card->
qdio.no_out_queues *
2392 if (!card->
qdio.out_qs)
2394 for (i = 0; i < card->
qdio.no_out_queues; ++
i) {
2397 if (!card->
qdio.out_qs[i])
2401 card->
qdio.out_qs[
i]->queue_no =
i;
2405 if (qeth_init_qdio_out_buf(card->
qdio.out_qs[i], j))
2406 goto out_freeoutqbufs;
2411 if (qeth_alloc_cq(card))
2420 card->
qdio.out_qs[i]->bufs[j]);
2426 qeth_clear_outq_buffers(card->
qdio.out_qs[i], 1);
2431 qeth_free_buffer_pool(card);
2440 static void qeth_create_qib_param_field(
struct qeth_card *card,
2444 param_field[0] =
_ascebc[
'P'];
2445 param_field[1] =
_ascebc[
'C'];
2446 param_field[2] =
_ascebc[
'I'];
2447 param_field[3] =
_ascebc[
'T'];
2453 static void qeth_create_qib_param_field_blkt(
struct qeth_card *card,
2456 param_field[16] =
_ascebc[
'B'];
2457 param_field[17] =
_ascebc[
'L'];
2458 param_field[18] =
_ascebc[
'K'];
2459 param_field[19] =
_ascebc[
'T'];
2460 *((
unsigned int *) (¶m_field[20])) = card->
info.blkt.time_total;
2461 *((
unsigned int *) (¶m_field[24])) = card->
info.blkt.inter_packet;
2462 *((
unsigned int *) (¶m_field[28])) =
2463 card->
info.blkt.inter_packet_jumbo;
2466 static int qeth_qdio_activate(
struct qeth_card *card)
2472 static int qeth_dm_act(
struct qeth_card *card)
2490 static int qeth_mpc_initialize(
struct qeth_card *card)
2496 rc = qeth_issue_next_read(card);
2501 rc = qeth_cm_enable(card);
2506 rc = qeth_cm_setup(card);
2511 rc = qeth_ulp_enable(card);
2516 rc = qeth_ulp_setup(card);
2521 rc = qeth_alloc_qdio_buffers(card);
2526 rc = qeth_qdio_establish(card);
2529 qeth_free_qdio_buffers(card);
2532 rc = qeth_qdio_activate(card);
2537 rc = qeth_dm_act(card);
2549 static void qeth_print_status_with_portname(
struct qeth_card *card)
2555 for (i = 0; i < 8; i++)
2559 dev_info(&card->
gdev->dev,
"Device is a%s card%s%s%s\n"
2560 "with link type %s (portname: %s)\n",
2561 qeth_get_cardname(card),
2562 (card->
info.mcl_level[0]) ?
" (level: " :
"",
2563 (card->
info.mcl_level[0]) ? card->
info.mcl_level :
"",
2564 (card->
info.mcl_level[0]) ?
")" :
"",
2570 static void qeth_print_status_no_portname(
struct qeth_card *card)
2572 if (card->
info.portname[0])
2574 "card%s%s%s\nwith link type %s "
2575 "(no portname needed by interface).\n",
2576 qeth_get_cardname(card),
2577 (card->
info.mcl_level[0]) ?
" (level: " :
"",
2578 (card->
info.mcl_level[0]) ? card->
info.mcl_level :
"",
2579 (card->
info.mcl_level[0]) ?
")" :
"",
2583 "card%s%s%s\nwith link type %s.\n",
2584 qeth_get_cardname(card),
2585 (card->
info.mcl_level[0]) ?
" (level: " :
"",
2586 (card->
info.mcl_level[0]) ? card->
info.mcl_level :
"",
2587 (card->
info.mcl_level[0]) ?
")" :
"",
2593 switch (card->
info.type) {
2601 if (!card->
info.mcl_level[0]) {
2603 card->
info.mcl_level[2],
2604 card->
info.mcl_level[3]);
2611 if ((card->
info.guestlan) ||
2612 (card->
info.mcl_level[0] & 0x80)) {
2614 card->
info.mcl_level[0]];
2616 card->
info.mcl_level[1]];
2618 card->
info.mcl_level[2]];
2620 card->
info.mcl_level[3]];
2627 if (card->
info.portname_required)
2628 qeth_print_status_with_portname(card);
2630 qeth_print_status_no_portname(card);
2634 static void qeth_initialize_working_pool_list(
struct qeth_card *card)
2642 qeth_put_buffer_pool_entry(card, entry);
2654 if (list_empty(&card->
qdio.in_buf_pool.entry_list))
2667 list_del_init(&entry->
list);
2683 if (card->
options.performance_stats)
2688 list_del_init(&entry->
list);
2692 static int qeth_init_input_buffer(
struct qeth_card *card,
2704 pool_entry = qeth_find_free_buffer_pool_entry(card);
2722 buf->
buffer->element[i].eflags = 0;
2723 buf->
buffer->element[i].sflags = 0;
2737 QDIO_MAX_BUFFERS_PER_Q *
sizeof(
struct qdio_buffer));
2738 qeth_initialize_working_pool_list(card);
2740 for (i = 0; i < card->
qdio.in_buf_pool.buf_count - 1; ++
i)
2741 qeth_init_input_buffer(card, &card->
qdio.in_q->bufs[i]);
2742 card->
qdio.in_q->next_buf_to_init =
2743 card->
qdio.in_buf_pool.buf_count - 1;
2745 card->
qdio.in_buf_pool.buf_count - 1);
2752 rc = qeth_cq_init(card);
2758 for (i = 0; i < card->
qdio.no_out_queues; ++
i) {
2760 QDIO_MAX_BUFFERS_PER_Q *
sizeof(
struct qdio_buffer));
2762 qeth_clear_output_buffer(card->
qdio.out_qs[i],
2763 card->
qdio.out_qs[i]->bufs[j],
2767 card->
qdio.out_qs[
i]->next_buf_to_fill = 0;
2768 card->
qdio.out_qs[
i]->do_pack = 0;
2780 switch (link_type) {
2788 static void qeth_fill_ipacmd_header(
struct qeth_card *card,
2796 cmd->
hdr.adapter_type = qeth_get_ipa_adp_type(card->
info.link_type);
2797 cmd->
hdr.rel_adapter_no = (
__u8) card->
info.portno;
2799 cmd->
hdr.prim_version_no = 2;
2801 cmd->
hdr.prim_version_no = 1;
2802 cmd->
hdr.param_count = 1;
2803 cmd->
hdr.prot_version = prot;
2804 cmd->
hdr.ipa_supported = 0;
2805 cmd->
hdr.ipa_enabled = 0;
2816 qeth_fill_ipacmd_header(card, cmd, ipacmd, prot);
2851 iob, reply_cb, reply_param);
2874 struct qeth_reply *reply,
unsigned long data)
2881 if (cmd->
hdr.return_code == 0)
2882 cmd->
hdr.return_code =
2888 static int qeth_query_setadapterparms_cb(
struct qeth_card *card,
2889 struct qeth_reply *reply,
unsigned long data)
2897 card->
info.link_type =
2901 card->
options.adp.supported_funcs =
2937 static int qeth_query_ipassists_cb(
struct qeth_card *card,
2938 struct qeth_reply *reply,
unsigned long data)
2946 switch (cmd->
hdr.return_code) {
2954 if (cmd->
hdr.return_code) {
2957 dev_name(&card->
gdev->dev),
2958 cmd->
hdr.return_code);
2964 card->
options.ipa4.supported_funcs = cmd->
hdr.ipa_supported;
2965 card->
options.ipa4.enabled_funcs = cmd->
hdr.ipa_enabled;
2967 card->
options.ipa6.supported_funcs = cmd->
hdr.ipa_supported;
2968 card->
options.ipa6.enabled_funcs = cmd->
hdr.ipa_enabled;
2971 "\n", dev_name(&card->
gdev->dev));
2990 static int qeth_query_setdiagass_cb(
struct qeth_card *card,
2991 struct qeth_reply *reply,
unsigned long data)
2997 rc = cmd->
hdr.return_code;
3005 static int qeth_query_setdiagass(
struct qeth_card *card)
3028 tid->
ssid = ccwid.ssid;
3029 tid->
devno = ccwid.devno;
3033 if ((level >= 2) && (
stsi(info222, 2, 2, 2) == 0))
3035 if ((level >= 3) && (
stsi(info322, 3, 2, 2) == 0)) {
3036 EBCASC(info322->
vm[0].name,
sizeof(info322->
vm[0].name));
3043 static int qeth_hw_trap_cb(
struct qeth_card *card,
3044 struct qeth_reply *reply,
unsigned long data)
3050 rc = cmd->
hdr.return_code;
3073 qeth_get_trap_id(card,
3087 unsigned int qdio_error,
const char *dbftext)
3096 if ((buf->
element[15].sflags) == 0x12) {
3097 card->
stats.rx_dropped++;
3125 card->
qdio.in_buf_pool.buf_count -
3127 card->
qdio.in_buf_pool.buf_count -
3133 if (qeth_init_input_buffer(card,
3134 &queue->
bufs[i % QDIO_MAX_BUFFERS_PER_Q])) {
3141 if (newcount < count) {
3154 if (i == card->
qdio.in_buf_pool.buf_count) {
3171 if (card->
options.performance_stats) {
3173 card->
perf_stats.inbound_do_qdio_start_time =
3178 if (card->
options.performance_stats)
3186 QDIO_MAX_BUFFERS_PER_Q;
3191 static int qeth_handle_send_error(
struct qeth_card *card,
3194 int sbalf15 = buffer->
buffer->element[15].sflags;
3209 if ((sbalf15 >= 15) && (sbalf15 <= 31))
3214 (
u16)qdio_err, (
u8)sbalf15);
3222 static void qeth_switch_to_packing_if_needed(
struct qeth_qdio_out_q *queue)
3229 if (queue->
card->options.performance_stats)
3230 queue->
card->perf_stats.sc_dp_p++;
3242 static int qeth_switch_to_nonpacking_if_needed(
struct qeth_qdio_out_q *queue)
3245 int flush_count = 0;
3252 if (queue->
card->options.performance_stats)
3253 queue->
card->perf_stats.sc_p_dp++;
3265 QDIO_MAX_BUFFERS_PER_Q;
3278 static int qeth_flush_buffers_on_no_pci(
struct qeth_qdio_out_q *queue)
3294 static void qeth_flush_buffers(
struct qeth_qdio_out_q *queue,
int index,
3300 unsigned int qdio_flags;
3302 for (i = index; i < index +
count; ++
i) {
3304 buf = queue->
bufs[bidx];
3341 if (queue->
card->options.performance_stats) {
3342 queue->
card->perf_stats.outbound_do_qdio_cnt++;
3343 queue->
card->perf_stats.outbound_do_qdio_start_time =
3351 if (queue->
card->options.performance_stats)
3352 queue->
card->perf_stats.outbound_do_qdio_time +=
3354 queue->
card->perf_stats.outbound_do_qdio_start_time;
3372 if (queue->
card->options.performance_stats)
3373 queue->
card->perf_stats.bufs_sent +=
count;
3380 int q_was_packing = 0;
3395 netif_stop_queue(queue->
card->dev);
3397 q_was_packing = queue->
do_pack;
3400 flush_cnt += qeth_switch_to_nonpacking_if_needed(queue);
3404 qeth_flush_buffers_on_no_pci(queue);
3405 if (queue->
card->options.performance_stats &&
3407 queue->
card->perf_stats.bufs_sent_pack +=
3410 qeth_flush_buffers(queue, index, flush_cnt);
3417 unsigned long card_ptr)
3422 napi_schedule(&card->
napi);
3445 qeth_free_qdio_buffers(card);
3456 static void qeth_qdio_cq_handler(
struct qeth_card *card,
3457 unsigned int qdio_err,
3458 unsigned int queue,
int first_element,
int count) {
3463 if (!qeth_is_cq(card, queue))
3471 netif_stop_queue(card->
dev);
3476 if (card->
options.performance_stats) {
3478 card->
perf_stats.cq_start_time = qeth_get_micros();
3481 for (i = first_element; i < first_element +
count; ++
i) {
3487 while (buffer->
element[e].addr) {
3488 unsigned long phys_aob_addr;
3490 phys_aob_addr = (
unsigned long) buffer->
element[e].addr;
3491 qeth_qdio_handle_aob(card, phys_aob_addr);
3500 buffer->
element[15].eflags = 0;
3501 buffer->
element[15].sflags = 0;
3504 card->
qdio.c_q->next_buf_to_init,
3508 "QDIO reported an error, rc=%i\n", rc);
3511 card->
qdio.c_q->next_buf_to_init = (card->
qdio.c_q->next_buf_to_init
3512 +
count) % QDIO_MAX_BUFFERS_PER_Q;
3514 netif_wake_queue(card->
dev);
3516 if (card->
options.performance_stats) {
3517 int delta_t = qeth_get_micros();
3526 unsigned int queue,
int first_elem,
int count,
3527 unsigned long card_ptr)
3534 if (qeth_is_cq(card, queue))
3535 qeth_qdio_cq_handler(card, qdio_err, queue, first_elem, count);
3545 int count,
unsigned long card_ptr)
3555 netif_stop_queue(card->
dev);
3559 if (card->
options.performance_stats) {
3561 card->
perf_stats.outbound_handler_start_time =
3564 for (i = first_element; i < (first_element +
count); ++
i) {
3566 buffer = queue->
bufs[bidx];
3567 qeth_handle_send_error(card, buffer, qdio_error);
3578 qeth_notify_skbs(queue, buffer,
3586 BUG_ON(bidx < 0 || bidx >= QDIO_MAX_BUFFERS_PER_Q);
3587 if (qeth_init_qdio_out_buf(queue, bidx)) {
3595 n = qeth_compute_cq_notification(
3596 buffer->
buffer->element[15].sflags, 0);
3597 qeth_notify_skbs(queue, buffer, n);
3600 qeth_clear_output_buffer(queue, buffer,
3603 qeth_cleanup_handled_pending(queue, bidx, 0);
3608 qeth_check_outbound_queue(queue);
3610 netif_wake_queue(queue->
card->dev);
3611 if (card->
options.performance_stats)
3612 card->
perf_stats.outbound_handler_time += qeth_get_micros() -
3613 card->
perf_stats.outbound_handler_start_time;
3618 int ipv,
int cast_type)
3622 return card->
qdio.default_out_queue;
3623 switch (card->
qdio.no_out_queues) {
3625 if (cast_type && card->
info.is_multicast_different)
3626 return card->
info.is_multicast_different &
3627 (card->
qdio.no_out_queues - 1);
3628 if (card->
qdio.do_prio_queueing && (ipv == 4)) {
3629 const u8 tos = ip_hdr(skb)->tos;
3631 if (card->
qdio.do_prio_queueing ==
3642 if (card->
qdio.do_prio_queueing ==
3644 return 3 - (tos >> 6);
3645 }
else if (card->
qdio.do_prio_queueing && (ipv == 6)) {
3648 return card->
qdio.default_out_queue;
3651 return card->
qdio.default_out_queue;
3657 struct sk_buff *skb,
int elems)
3660 int elements_needed =
PFN_UP((
unsigned long)skb->
data + dlen - 1) -
3663 elements_needed += skb_shinfo(skb)->nr_frags;
3666 "(Number=%d / Length=%d). Discarded.\n",
3667 (elements_needed+elems), skb->
len);
3670 return elements_needed;
3676 int hroom, inpage,
rest;
3679 (((
unsigned long)skb->
data + len - 1) & PAGE_MASK)) {
3680 hroom = skb_headroom(skb);
3682 rest = len - inpage;
3693 static inline void __qeth_fill_buffer(
struct sk_buff *skb,
3704 element = *next_element_to_fill;
3706 first_lap = (is_tso == 0 ? 1 : 0);
3714 while (length > 0) {
3717 if (length < length_here)
3722 length -= length_here;
3725 if (skb_shinfo(skb)->nr_frags)
3741 data += length_here;
3746 for (cnt = 0; cnt < skb_shinfo(skb)->nr_frags; cnt++) {
3747 frag = &skb_shinfo(skb)->frags[
cnt];
3756 if (buffer->
element[element - 1].eflags)
3758 *next_element_to_fill =
element;
3766 int flush_cnt = 0,
hdr_len, large_send = 0;
3798 __qeth_fill_buffer(skb, buffer, large_send,
3808 if (queue->
card->options.performance_stats)
3809 queue->
card->perf_stats.skbs_sent_pack++;
3825 struct qeth_hdr *hdr,
int elements_needed,
3826 int offset,
int hd_len)
3844 QDIO_MAX_BUFFERS_PER_Q;
3846 qeth_fill_buffer(queue, buffer, skb, hdr, offset, hd_len);
3847 qeth_flush_buffers(queue, index, 1);
3857 int elements_needed)
3861 int flush_count = 0;
3880 qeth_switch_to_packing_if_needed(queue);
3891 QDIO_MAX_BUFFERS_PER_Q;
3897 qeth_flush_buffers(queue, start_index,
3905 tmp = qeth_fill_buffer(queue, buffer, skb, hdr, -1, 0);
3907 QDIO_MAX_BUFFERS_PER_Q;
3910 qeth_flush_buffers(queue, start_index, flush_count);
3923 flush_count += qeth_switch_to_nonpacking_if_needed(queue);
3929 flush_count += qeth_flush_buffers_on_no_pci(queue);
3931 qeth_flush_buffers(queue, start_index, flush_count);
3934 if (queue->
card->options.performance_stats && do_pack)
3935 queue->
card->perf_stats.bufs_sent_pack += flush_count;
3941 static int qeth_setadp_promisc_mode_cb(
struct qeth_card *card,
3942 struct qeth_reply *reply,
unsigned long data)
3953 if (cmd->
hdr.return_code) {
3996 sprintf(dbf_text,
"%8x", new_mtu);
4001 if (new_mtu > 65535)
4004 (!qeth_mtu_is_valid(card, new_mtu)))
4019 return &card->
stats;
4023 static int qeth_setadpparms_change_macaddr_cb(
struct qeth_card *card,
4024 struct qeth_reply *reply,
unsigned long data)
4063 static int qeth_setadpparms_set_access_ctrl_cb(
struct qeth_card *card,
4064 struct qeth_reply *reply,
unsigned long data)
4085 "QDIO data connection isolation is deactivated\n");
4088 "QDIO data connection isolation is activated\n");
4091 card->
gdev->dev.kobj.name,
4099 card->
gdev->dev.kobj.name,
4103 "support QDIO data connection isolation\n");
4112 card->
gdev->dev.kobj.name,
4116 "Adapter is dedicated. "
4117 "QDIO data connection isolation not supported\n");
4126 card->
gdev->dev.kobj.name,
4130 "TSO does not permit QDIO data connection isolation\n");
4141 card->
gdev->dev.kobj.name,
4154 static int qeth_setadpparms_set_access_ctrl(
struct qeth_card *card,
4189 rc = qeth_setadpparms_set_access_ctrl(card,
4193 "IPA(SET_ACCESS_CTRL,%s,%d) sent failed\n",
4194 card->
gdev->dev.kobj.name,
4201 "support QDIO data connection isolation\n");
4214 card->
stats.tx_errors++;
4240 rc = (rc >> 5) & 0xFFFF;
4243 rc = (dev->
dev_addr[2] << 10) & 0xFFFF;
4261 rc = card->
stats.rx_errors;
4284 static int qeth_send_ipa_snmp_cmd(
struct qeth_card *card,
4305 reply_cb, reply_param);
4308 static int qeth_snmp_command_cb(
struct qeth_card *card,
4314 unsigned char *
data;
4320 data = (
unsigned char *)((
char *)cmd - reply->
offset);
4324 if (cmd->
hdr.return_code) {
4329 cmd->
hdr.return_code =
4336 data_len -= (
__u16)((
char *)&snmp->
data - (
char *)cmd);
4338 data_len -= (
__u16)((
char *)&snmp->
request - (
char *)cmd);
4358 (
char *)&snmp->
request, data_len);
4383 if (card->
info.guestlan)
4396 return PTR_ERR(ureq);
4411 qeth_snmp_command_cb, (
void *)&qinfo);
4426 static int qeth_setadpparms_query_oat_cb(
struct qeth_card *card,
4427 struct qeth_reply *reply,
unsigned long data)
4439 resdata = (
char *)data + 28;
4498 tmp = compat_ptr(oat_data.
ptr);
4500 tmp = (
void __user *)(
unsigned long)oat_data.
ptr;
4524 static inline int qeth_get_qdio_q_format(
struct qeth_card *card)
4526 switch (card->
info.type) {
4534 static void qeth_determine_capabilities(
struct qeth_card *card)
4540 int ddev_offline = 0;
4553 rc = qeth_read_conf_data(card, (
void **) &prcd, &length);
4556 dev_name(&card->
gdev->dev), rc);
4560 qeth_configure_unitaddr(card, prcd);
4562 qeth_configure_blkt_default(card, prcd);
4577 "Completion Queueing supported\n");
4584 if (ddev_offline == 1)
4590 static inline void qeth_qdio_establish_cq(
struct qeth_card *card,
4592 void (**queue_start_poll) (
struct ccw_device *,
int,
unsigned long)) {
4596 int offset = QDIO_MAX_BUFFERS_PER_Q *
4597 (card->
qdio.no_in_queues - 1);
4598 i = QDIO_MAX_BUFFERS_PER_Q * (card->
qdio.no_in_queues - 1);
4604 queue_start_poll[card->
qdio.no_in_queues - 1] =
NULL;
4608 static int qeth_qdio_establish(
struct qeth_card *card)
4620 qib_param_field = kzalloc(QDIO_MAX_BUFFERS_PER_Q *
sizeof(
char),
4622 if (!qib_param_field) {
4624 goto out_free_nothing;
4627 qeth_create_qib_param_field(card, qib_param_field);
4628 qeth_create_qib_param_field_blkt(card, qib_param_field);
4630 in_sbal_ptrs = kzalloc(card->
qdio.no_in_queues *
4631 QDIO_MAX_BUFFERS_PER_Q *
sizeof(
void *),
4633 if (!in_sbal_ptrs) {
4635 goto out_free_qib_param;
4642 queue_start_poll = kzalloc(
sizeof(
void *) * card->
qdio.no_in_queues,
4644 if (!queue_start_poll) {
4646 goto out_free_in_sbals;
4648 for (i = 0; i < card->
qdio.no_in_queues; ++
i)
4649 queue_start_poll[i] = card->
discipline->start_poll;
4651 qeth_qdio_establish_cq(card, in_sbal_ptrs, queue_start_poll);
4654 kzalloc(card->
qdio.no_out_queues * QDIO_MAX_BUFFERS_PER_Q *
4656 if (!out_sbal_ptrs) {
4658 goto out_free_queue_start_poll;
4660 for (i = 0, k = 0; i < card->
qdio.no_out_queues; ++
i)
4663 card->
qdio.out_qs[i]->bufs[j]->buffer);
4668 init_data.q_format = qeth_get_qdio_q_format(card);
4669 init_data.qib_param_field_format = 0;
4670 init_data.qib_param_field = qib_param_field;
4671 init_data.no_input_qs = card->
qdio.no_in_queues;
4672 init_data.no_output_qs = card->
qdio.no_out_queues;
4673 init_data.input_handler = card->
discipline->input_handler;
4674 init_data.output_handler = card->
discipline->output_handler;
4675 init_data.queue_start_poll_array = queue_start_poll;
4676 init_data.int_parm = (
unsigned long) card;
4677 init_data.input_sbal_addr_array = (
void **) in_sbal_ptrs;
4678 init_data.output_sbal_addr_array = (
void **) out_sbal_ptrs;
4679 init_data.output_sbal_state_array = card->
qdio.out_bufstates;
4680 init_data.scan_threshold =
4699 dev_info(&card->
gdev->dev,
"Completion Queue support enabled");
4702 dev_info(&card->
gdev->dev,
"Completion Queue support disabled");
4708 kfree(out_sbal_ptrs);
4709 out_free_queue_start_poll:
4710 kfree(queue_start_poll);
4712 kfree(in_sbal_ptrs);
4714 kfree(qib_param_field);
4719 static void qeth_core_free_card(
struct qeth_card *card)
4724 qeth_clean_channel(&card->
read);
4725 qeth_clean_channel(&card->
write);
4729 qeth_free_qdio_buffers(card);
4766 qeth_update_from_chp_desc(card);
4770 dev_name(&card->
gdev->dev));
4795 qeth_determine_capabilities(card);
4796 qeth_init_tokens(card);
4797 qeth_init_func_level(card);
4798 rc = qeth_idx_activate_channel(&card->
read, qeth_idx_read_cb);
4809 rc = qeth_idx_activate_channel(&card->
write, qeth_idx_write_cb);
4821 rc = qeth_mpc_initialize(card);
4827 card->
options.ipa4.supported_funcs = 0;
4828 card->
options.adp.supported_funcs = 0;
4829 card->
info.diagass_support = 0;
4834 qeth_query_setdiagass(card);
4837 dev_warn(&card->
gdev->dev,
"The qeth device driver failed to recover "
4838 "an error on the device\n");
4840 dev_name(&card->
gdev->dev), rc);
4845 static inline int qeth_create_skb_frag(
struct qeth_qdio_buffer *qethbuffer,
4847 struct sk_buff **pskb,
int offset,
int *pfrag,
int data_len)
4850 if (*pskb ==
NULL) {
4851 if (qethbuffer->
rx_skb) {
4853 *pskb = qethbuffer->
rx_skb;
4869 skb_fill_page_desc(*pskb, *pfrag, page,
4879 skb_fill_page_desc(*pskb, *pfrag, page, offset, data_len);
4897 int offset = *__offset;
4908 if (qeth_is_last_sbale(element))
4918 switch ((*hdr)->hdr.l2.id) {
4920 skb_len = (*hdr)->hdr.l2.pkt_length;
4923 skb_len = (*hdr)->hdr.l3.length;
4927 skb_len = (*hdr)->hdr.osn.pdu_length;
4928 headroom =
sizeof(
struct qeth_hdr);
4937 if (((skb_len >= card->
options.rx_sg_cb) &&
4943 skb = dev_alloc_skb(skb_len + headroom);
4947 skb_reserve(skb, headroom);
4952 data_len =
min(skb_len, (
int)(element->
length - offset));
4955 if (qeth_create_skb_frag(qethbuffer, element,
4956 &skb, offset, &frag, data_len))
4965 if (qeth_is_last_sbale(element)) {
4969 card->
stats.rx_errors++;
4974 data_ptr = element->
addr;
4981 if (use_rx_sg && card->
options.performance_stats) {
4983 card->
perf_stats.sg_frags_rx += skb_shinfo(skb)->nr_frags;
4990 card->
stats.rx_dropped++;
4995 static void qeth_unregister_dbf_views(
void)
5006 char dbf_txt_buf[32];
5009 if (level > id->
level)
5012 vsnprintf(dbf_txt_buf,
sizeof(dbf_txt_buf), fmt, args);
5014 debug_text_event(
id, level, dbf_txt_buf);
5018 static int qeth_register_dbf_views(
void)
5029 if (qeth_dbf[x].
id ==
NULL) {
5030 qeth_unregister_dbf_views();
5037 qeth_unregister_dbf_views();
5053 switch (discipline) {
5064 dev_err(&card->
gdev->dev,
"There is no kernel module to "
5065 "support discipline %d\n", discipline);
5081 static const struct device_type qeth_generic_devtype = {
5082 .name =
"qeth_generic",
5085 static const struct device_type qeth_osn_devtype = {
5095 unsigned long flags;
5106 card = qeth_alloc_card();
5113 snprintf(dbf_name,
sizeof(dbf_name),
"qeth_card_%s",
5114 dev_name(&gdev->
dev));
5128 gdev->
cdev[0]->handler = qeth_irq;
5129 gdev->
cdev[1]->handler = qeth_irq;
5130 gdev->
cdev[2]->handler = qeth_irq;
5132 rc = qeth_determine_card_type(card);
5137 rc = qeth_setup_card(card);
5144 gdev->
dev.type = &qeth_osn_devtype;
5146 gdev->
dev.type = &qeth_generic_devtype;
5148 switch (card->
info.type) {
5167 qeth_determine_capabilities(card);
5175 qeth_core_free_card(card);
5183 unsigned long flags;
5197 qeth_core_free_card(card);
5283 .setup = qeth_core_probe_device,
5284 .remove = qeth_core_remove_device,
5285 .set_online = qeth_core_set_online,
5286 .set_offline = qeth_core_set_offline,
5287 .shutdown = qeth_core_shutdown,
5288 .prepare = qeth_core_prepare,
5289 .complete = qeth_core_complete,
5290 .freeze = qeth_core_freeze,
5291 .thaw = qeth_core_thaw,
5292 .restore = qeth_core_restore,
5296 const char *buf,
size_t count)
5301 &qeth_core_ccwgroup_driver, 3, buf);
5303 return err ? err :
count;
5307 static struct attribute *qeth_drv_attrs[] = {
5308 &driver_attr_group.attr,
5312 .attrs = qeth_drv_attrs,
5315 &qeth_drv_attr_group,
5321 } qeth_ethtool_stats_keys[] = {
5326 {
"tx skbs no packing"},
5327 {
"tx buffers no packing"},
5328 {
"tx skbs packing"},
5329 {
"tx buffers packing"},
5334 {
"rx sg page allocs"},
5335 {
"tx large kbytes"},
5337 {
"tx pk state ch n->p"},
5338 {
"tx pk state ch p->n"},
5339 {
"tx pk watermark low"},
5340 {
"tx pk watermark high"},
5341 {
"queue 0 buffer usage"},
5342 {
"queue 1 buffer usage"},
5343 {
"queue 2 buffer usage"},
5344 {
"queue 3 buffer usage"},
5347 {
"rx do_QDIO time"},
5348 {
"rx do_QDIO count"},
5349 {
"tx handler time"},
5350 {
"tx handler count"},
5353 {
"tx do_QDIO time"},
5354 {
"tx do_QDIO count"},
5357 {
"cq handler count"},
5363 switch (stringset) {
5376 data[0] = card->
stats.rx_packets -
5379 data[2] = card->
stats.tx_packets -
5382 data[4] = card->
stats.tx_packets - card->
perf_stats.initial_tx_packets
5391 data[12] = card->
perf_stats.sg_alloc_page_rx;
5392 data[13] = (card->
perf_stats.large_send_bytes >> 10);
5399 data[20] = (card->
qdio.no_out_queues > 1) ?
5401 data[21] = (card->
qdio.no_out_queues > 2) ?
5403 data[22] = (card->
qdio.no_out_queues > 3) ?
5407 data[25] = card->
perf_stats.inbound_do_qdio_time;
5408 data[26] = card->
perf_stats.inbound_do_qdio_cnt;
5409 data[27] = card->
perf_stats.outbound_handler_time;
5410 data[28] = card->
perf_stats.outbound_handler_cnt;
5413 data[31] = card->
perf_stats.outbound_do_qdio_time;
5414 data[32] = card->
perf_stats.outbound_do_qdio_cnt;
5424 switch (stringset) {
5426 memcpy(data, &qeth_ethtool_stats_keys,
5427 sizeof(qeth_ethtool_stats_keys));
5463 link_type = card->
info.link_type;
5471 switch (link_type) {
5544 static int __init qeth_core_init(
void)
5548 pr_info(
"loading core functions\n");
5553 rc = qeth_register_dbf_views();
5557 rc = IS_ERR(qeth_core_root_dev) ? PTR_ERR(qeth_core_root_dev) : 0;
5562 if (!qeth_core_header_cache) {
5568 if (!qeth_qdio_outbuf_cache) {
5575 qeth_core_ccwgroup_driver.
driver.groups = qeth_drv_attr_groups;
5591 qeth_unregister_dbf_views();
5593 pr_err(
"Initializing the qeth device driver failed\n");
5597 static void __exit qeth_core_exit(
void)
5604 qeth_unregister_dbf_views();
5605 pr_info(
"core functions removed\n");