1 /* 2 * Copyright IBM Corp. 2007 3 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>, 4 * Frank Pavlic <fpavlic@de.ibm.com>, 5 * Thomas Spatzier <tspat@de.ibm.com>, 6 * Frank Blaschka <frank.blaschka@de.ibm.com> 7 */ 8 9 #define KMSG_COMPONENT "qeth" 10 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt 11 12 #include <linux/list.h> 13 #include <linux/rwsem.h> 14 #include <asm/ebcdic.h> 15 16 #include "qeth_core.h" 17 18 static ssize_t qeth_dev_state_show(struct device *dev, 19 struct device_attribute *attr, char *buf) 20 { 21 struct qeth_card *card = dev_get_drvdata(dev); 22 if (!card) 23 return -EINVAL; 24 25 switch (card->state) { 26 case CARD_STATE_DOWN: 27 return sprintf(buf, "DOWN\n"); 28 case CARD_STATE_HARDSETUP: 29 return sprintf(buf, "HARDSETUP\n"); 30 case CARD_STATE_SOFTSETUP: 31 return sprintf(buf, "SOFTSETUP\n"); 32 case CARD_STATE_UP: 33 if (card->lan_online) 34 return sprintf(buf, "UP (LAN ONLINE)\n"); 35 else 36 return sprintf(buf, "UP (LAN OFFLINE)\n"); 37 case CARD_STATE_RECOVER: 38 return sprintf(buf, "RECOVER\n"); 39 default: 40 return sprintf(buf, "UNKNOWN\n"); 41 } 42 } 43 44 static DEVICE_ATTR(state, 0444, qeth_dev_state_show, NULL); 45 46 static ssize_t qeth_dev_chpid_show(struct device *dev, 47 struct device_attribute *attr, char *buf) 48 { 49 struct qeth_card *card = dev_get_drvdata(dev); 50 if (!card) 51 return -EINVAL; 52 53 return sprintf(buf, "%02X\n", card->info.chpid); 54 } 55 56 static DEVICE_ATTR(chpid, 0444, qeth_dev_chpid_show, NULL); 57 58 static ssize_t qeth_dev_if_name_show(struct device *dev, 59 struct device_attribute *attr, char *buf) 60 { 61 struct qeth_card *card = dev_get_drvdata(dev); 62 if (!card) 63 return -EINVAL; 64 return sprintf(buf, "%s\n", QETH_CARD_IFNAME(card)); 65 } 66 67 static DEVICE_ATTR(if_name, 0444, qeth_dev_if_name_show, NULL); 68 69 static ssize_t qeth_dev_card_type_show(struct device *dev, 70 struct device_attribute *attr, char *buf) 71 { 72 struct qeth_card *card = dev_get_drvdata(dev); 73 if (!card) 74 return -EINVAL; 75 76 return sprintf(buf, "%s\n", qeth_get_cardname_short(card)); 77 } 78 79 static DEVICE_ATTR(card_type, 0444, qeth_dev_card_type_show, NULL); 80 81 static inline const char *qeth_get_bufsize_str(struct qeth_card *card) 82 { 83 if (card->qdio.in_buf_size == 16384) 84 return "16k"; 85 else if (card->qdio.in_buf_size == 24576) 86 return "24k"; 87 else if (card->qdio.in_buf_size == 32768) 88 return "32k"; 89 else if (card->qdio.in_buf_size == 40960) 90 return "40k"; 91 else 92 return "64k"; 93 } 94 95 static ssize_t qeth_dev_inbuf_size_show(struct device *dev, 96 struct device_attribute *attr, char *buf) 97 { 98 struct qeth_card *card = dev_get_drvdata(dev); 99 if (!card) 100 return -EINVAL; 101 102 return sprintf(buf, "%s\n", qeth_get_bufsize_str(card)); 103 } 104 105 static DEVICE_ATTR(inbuf_size, 0444, qeth_dev_inbuf_size_show, NULL); 106 107 static ssize_t qeth_dev_portno_show(struct device *dev, 108 struct device_attribute *attr, char *buf) 109 { 110 struct qeth_card *card = dev_get_drvdata(dev); 111 if (!card) 112 return -EINVAL; 113 114 return sprintf(buf, "%i\n", card->info.portno); 115 } 116 117 static ssize_t qeth_dev_portno_store(struct device *dev, 118 struct device_attribute *attr, const char *buf, size_t count) 119 { 120 struct qeth_card *card = dev_get_drvdata(dev); 121 char *tmp; 122 unsigned int portno, limit; 123 int rc = 0; 124 125 if (!card) 126 return -EINVAL; 127 128 mutex_lock(&card->conf_mutex); 129 if ((card->state != CARD_STATE_DOWN) && 130 (card->state != CARD_STATE_RECOVER)) { 131 rc = -EPERM; 132 goto out; 133 } 134 135 portno = simple_strtoul(buf, &tmp, 16); 136 if (portno > QETH_MAX_PORTNO) { 137 rc = -EINVAL; 138 goto out; 139 } 140 limit = (card->ssqd.pcnt ? card->ssqd.pcnt - 1 : card->ssqd.pcnt); 141 if (portno > limit) { 142 rc = -EINVAL; 143 goto out; 144 } 145 card->info.portno = portno; 146 out: 147 mutex_unlock(&card->conf_mutex); 148 return rc ? rc : count; 149 } 150 151 static DEVICE_ATTR(portno, 0644, qeth_dev_portno_show, qeth_dev_portno_store); 152 153 static ssize_t qeth_dev_portname_show(struct device *dev, 154 struct device_attribute *attr, char *buf) 155 { 156 struct qeth_card *card = dev_get_drvdata(dev); 157 char portname[9] = {0, }; 158 159 if (!card) 160 return -EINVAL; 161 162 if (card->info.portname_required) { 163 memcpy(portname, card->info.portname + 1, 8); 164 EBCASC(portname, 8); 165 return sprintf(buf, "%s\n", portname); 166 } else 167 return sprintf(buf, "no portname required\n"); 168 } 169 170 static ssize_t qeth_dev_portname_store(struct device *dev, 171 struct device_attribute *attr, const char *buf, size_t count) 172 { 173 struct qeth_card *card = dev_get_drvdata(dev); 174 char *tmp; 175 int i, rc = 0; 176 177 if (!card) 178 return -EINVAL; 179 180 mutex_lock(&card->conf_mutex); 181 if ((card->state != CARD_STATE_DOWN) && 182 (card->state != CARD_STATE_RECOVER)) { 183 rc = -EPERM; 184 goto out; 185 } 186 187 tmp = strsep((char **) &buf, "\n"); 188 if ((strlen(tmp) > 8) || (strlen(tmp) == 0)) { 189 rc = -EINVAL; 190 goto out; 191 } 192 193 card->info.portname[0] = strlen(tmp); 194 /* for beauty reasons */ 195 for (i = 1; i < 9; i++) 196 card->info.portname[i] = ' '; 197 strcpy(card->info.portname + 1, tmp); 198 ASCEBC(card->info.portname + 1, 8); 199 out: 200 mutex_unlock(&card->conf_mutex); 201 return rc ? rc : count; 202 } 203 204 static DEVICE_ATTR(portname, 0644, qeth_dev_portname_show, 205 qeth_dev_portname_store); 206 207 static ssize_t qeth_dev_prioqing_show(struct device *dev, 208 struct device_attribute *attr, char *buf) 209 { 210 struct qeth_card *card = dev_get_drvdata(dev); 211 212 if (!card) 213 return -EINVAL; 214 215 switch (card->qdio.do_prio_queueing) { 216 case QETH_PRIO_Q_ING_PREC: 217 return sprintf(buf, "%s\n", "by precedence"); 218 case QETH_PRIO_Q_ING_TOS: 219 return sprintf(buf, "%s\n", "by type of service"); 220 case QETH_PRIO_Q_ING_SKB: 221 return sprintf(buf, "%s\n", "by skb-priority"); 222 case QETH_PRIO_Q_ING_VLAN: 223 return sprintf(buf, "%s\n", "by VLAN headers"); 224 default: 225 return sprintf(buf, "always queue %i\n", 226 card->qdio.default_out_queue); 227 } 228 } 229 230 static ssize_t qeth_dev_prioqing_store(struct device *dev, 231 struct device_attribute *attr, const char *buf, size_t count) 232 { 233 struct qeth_card *card = dev_get_drvdata(dev); 234 char *tmp; 235 int rc = 0; 236 237 if (!card) 238 return -EINVAL; 239 240 mutex_lock(&card->conf_mutex); 241 if ((card->state != CARD_STATE_DOWN) && 242 (card->state != CARD_STATE_RECOVER)) { 243 rc = -EPERM; 244 goto out; 245 } 246 247 /* check if 1920 devices are supported , 248 * if though we have to permit priority queueing 249 */ 250 if (card->qdio.no_out_queues == 1) { 251 card->qdio.do_prio_queueing = QETH_PRIOQ_DEFAULT; 252 rc = -EPERM; 253 goto out; 254 } 255 256 tmp = strsep((char **) &buf, "\n"); 257 if (!strcmp(tmp, "prio_queueing_prec")) { 258 card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_PREC; 259 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; 260 } else if (!strcmp(tmp, "prio_queueing_skb")) { 261 card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_SKB; 262 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; 263 } else if (!strcmp(tmp, "prio_queueing_tos")) { 264 card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_TOS; 265 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; 266 } else if (!strcmp(tmp, "prio_queueing_vlan")) { 267 if (!card->options.layer2) { 268 rc = -ENOTSUPP; 269 goto out; 270 } 271 card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_VLAN; 272 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; 273 } else if (!strcmp(tmp, "no_prio_queueing:0")) { 274 card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; 275 card->qdio.default_out_queue = 0; 276 } else if (!strcmp(tmp, "no_prio_queueing:1")) { 277 card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; 278 card->qdio.default_out_queue = 1; 279 } else if (!strcmp(tmp, "no_prio_queueing:2")) { 280 card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; 281 card->qdio.default_out_queue = 2; 282 } else if (!strcmp(tmp, "no_prio_queueing:3")) { 283 card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; 284 card->qdio.default_out_queue = 3; 285 } else if (!strcmp(tmp, "no_prio_queueing")) { 286 card->qdio.do_prio_queueing = QETH_NO_PRIO_QUEUEING; 287 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE; 288 } else 289 rc = -EINVAL; 290 out: 291 mutex_unlock(&card->conf_mutex); 292 return rc ? rc : count; 293 } 294 295 static DEVICE_ATTR(priority_queueing, 0644, qeth_dev_prioqing_show, 296 qeth_dev_prioqing_store); 297 298 static ssize_t qeth_dev_bufcnt_show(struct device *dev, 299 struct device_attribute *attr, char *buf) 300 { 301 struct qeth_card *card = dev_get_drvdata(dev); 302 303 if (!card) 304 return -EINVAL; 305 306 return sprintf(buf, "%i\n", card->qdio.in_buf_pool.buf_count); 307 } 308 309 static ssize_t qeth_dev_bufcnt_store(struct device *dev, 310 struct device_attribute *attr, const char *buf, size_t count) 311 { 312 struct qeth_card *card = dev_get_drvdata(dev); 313 char *tmp; 314 int cnt, old_cnt; 315 int rc = 0; 316 317 if (!card) 318 return -EINVAL; 319 320 mutex_lock(&card->conf_mutex); 321 if ((card->state != CARD_STATE_DOWN) && 322 (card->state != CARD_STATE_RECOVER)) { 323 rc = -EPERM; 324 goto out; 325 } 326 327 old_cnt = card->qdio.in_buf_pool.buf_count; 328 cnt = simple_strtoul(buf, &tmp, 10); 329 cnt = (cnt < QETH_IN_BUF_COUNT_MIN) ? QETH_IN_BUF_COUNT_MIN : 330 ((cnt > QETH_IN_BUF_COUNT_MAX) ? QETH_IN_BUF_COUNT_MAX : cnt); 331 if (old_cnt != cnt) { 332 rc = qeth_realloc_buffer_pool(card, cnt); 333 } 334 out: 335 mutex_unlock(&card->conf_mutex); 336 return rc ? rc : count; 337 } 338 339 static DEVICE_ATTR(buffer_count, 0644, qeth_dev_bufcnt_show, 340 qeth_dev_bufcnt_store); 341 342 static ssize_t qeth_dev_recover_store(struct device *dev, 343 struct device_attribute *attr, const char *buf, size_t count) 344 { 345 struct qeth_card *card = dev_get_drvdata(dev); 346 char *tmp; 347 int i; 348 349 if (!card) 350 return -EINVAL; 351 352 if (card->state != CARD_STATE_UP) 353 return -EPERM; 354 355 i = simple_strtoul(buf, &tmp, 16); 356 if (i == 1) 357 qeth_schedule_recovery(card); 358 359 return count; 360 } 361 362 static DEVICE_ATTR(recover, 0200, NULL, qeth_dev_recover_store); 363 364 static ssize_t qeth_dev_performance_stats_show(struct device *dev, 365 struct device_attribute *attr, char *buf) 366 { 367 struct qeth_card *card = dev_get_drvdata(dev); 368 369 if (!card) 370 return -EINVAL; 371 372 return sprintf(buf, "%i\n", card->options.performance_stats ? 1:0); 373 } 374 375 static ssize_t qeth_dev_performance_stats_store(struct device *dev, 376 struct device_attribute *attr, const char *buf, size_t count) 377 { 378 struct qeth_card *card = dev_get_drvdata(dev); 379 char *tmp; 380 int i, rc = 0; 381 382 if (!card) 383 return -EINVAL; 384 385 mutex_lock(&card->conf_mutex); 386 i = simple_strtoul(buf, &tmp, 16); 387 if ((i == 0) || (i == 1)) { 388 if (i == card->options.performance_stats) 389 goto out; 390 card->options.performance_stats = i; 391 if (i == 0) 392 memset(&card->perf_stats, 0, 393 sizeof(struct qeth_perf_stats)); 394 card->perf_stats.initial_rx_packets = card->stats.rx_packets; 395 card->perf_stats.initial_tx_packets = card->stats.tx_packets; 396 } else 397 rc = -EINVAL; 398 out: 399 mutex_unlock(&card->conf_mutex); 400 return rc ? rc : count; 401 } 402 403 static DEVICE_ATTR(performance_stats, 0644, qeth_dev_performance_stats_show, 404 qeth_dev_performance_stats_store); 405 406 static ssize_t qeth_dev_layer2_show(struct device *dev, 407 struct device_attribute *attr, char *buf) 408 { 409 struct qeth_card *card = dev_get_drvdata(dev); 410 411 if (!card) 412 return -EINVAL; 413 414 return sprintf(buf, "%i\n", card->options.layer2); 415 } 416 417 static ssize_t qeth_dev_layer2_store(struct device *dev, 418 struct device_attribute *attr, const char *buf, size_t count) 419 { 420 struct qeth_card *card = dev_get_drvdata(dev); 421 char *tmp; 422 int i, rc = 0; 423 enum qeth_discipline_id newdis; 424 425 if (!card) 426 return -EINVAL; 427 428 mutex_lock(&card->discipline_mutex); 429 if (card->state != CARD_STATE_DOWN) { 430 rc = -EPERM; 431 goto out; 432 } 433 434 i = simple_strtoul(buf, &tmp, 16); 435 switch (i) { 436 case 0: 437 newdis = QETH_DISCIPLINE_LAYER3; 438 break; 439 case 1: 440 newdis = QETH_DISCIPLINE_LAYER2; 441 break; 442 default: 443 rc = -EINVAL; 444 goto out; 445 } 446 447 if (card->options.layer2 == newdis) 448 goto out; 449 else { 450 card->info.mac_bits = 0; 451 if (card->discipline) { 452 card->discipline->remove(card->gdev); 453 qeth_core_free_discipline(card); 454 } 455 } 456 457 rc = qeth_core_load_discipline(card, newdis); 458 if (rc) 459 goto out; 460 461 rc = card->discipline->setup(card->gdev); 462 out: 463 mutex_unlock(&card->discipline_mutex); 464 return rc ? rc : count; 465 } 466 467 static DEVICE_ATTR(layer2, 0644, qeth_dev_layer2_show, 468 qeth_dev_layer2_store); 469 470 #define ATTR_QETH_ISOLATION_NONE ("none") 471 #define ATTR_QETH_ISOLATION_FWD ("forward") 472 #define ATTR_QETH_ISOLATION_DROP ("drop") 473 474 static ssize_t qeth_dev_isolation_show(struct device *dev, 475 struct device_attribute *attr, char *buf) 476 { 477 struct qeth_card *card = dev_get_drvdata(dev); 478 479 if (!card) 480 return -EINVAL; 481 482 switch (card->options.isolation) { 483 case ISOLATION_MODE_NONE: 484 return snprintf(buf, 6, "%s\n", ATTR_QETH_ISOLATION_NONE); 485 case ISOLATION_MODE_FWD: 486 return snprintf(buf, 9, "%s\n", ATTR_QETH_ISOLATION_FWD); 487 case ISOLATION_MODE_DROP: 488 return snprintf(buf, 6, "%s\n", ATTR_QETH_ISOLATION_DROP); 489 default: 490 return snprintf(buf, 5, "%s\n", "N/A"); 491 } 492 } 493 494 static ssize_t qeth_dev_isolation_store(struct device *dev, 495 struct device_attribute *attr, const char *buf, size_t count) 496 { 497 struct qeth_card *card = dev_get_drvdata(dev); 498 enum qeth_ipa_isolation_modes isolation; 499 int rc = 0; 500 char *tmp, *curtoken; 501 curtoken = (char *) buf; 502 503 if (!card) 504 return -EINVAL; 505 506 mutex_lock(&card->conf_mutex); 507 /* check for unknown, too, in case we do not yet know who we are */ 508 if (card->info.type != QETH_CARD_TYPE_OSD && 509 card->info.type != QETH_CARD_TYPE_OSX && 510 card->info.type != QETH_CARD_TYPE_UNKNOWN) { 511 rc = -EOPNOTSUPP; 512 dev_err(&card->gdev->dev, "Adapter does not " 513 "support QDIO data connection isolation\n"); 514 goto out; 515 } 516 517 /* parse input into isolation mode */ 518 tmp = strsep(&curtoken, "\n"); 519 if (!strcmp(tmp, ATTR_QETH_ISOLATION_NONE)) { 520 isolation = ISOLATION_MODE_NONE; 521 } else if (!strcmp(tmp, ATTR_QETH_ISOLATION_FWD)) { 522 isolation = ISOLATION_MODE_FWD; 523 } else if (!strcmp(tmp, ATTR_QETH_ISOLATION_DROP)) { 524 isolation = ISOLATION_MODE_DROP; 525 } else { 526 rc = -EINVAL; 527 goto out; 528 } 529 rc = count; 530 531 /* defer IP assist if device is offline (until discipline->set_online)*/ 532 card->options.prev_isolation = card->options.isolation; 533 card->options.isolation = isolation; 534 if (card->state == CARD_STATE_SOFTSETUP || 535 card->state == CARD_STATE_UP) { 536 int ipa_rc = qeth_set_access_ctrl_online(card, 1); 537 if (ipa_rc != 0) 538 rc = ipa_rc; 539 } 540 out: 541 mutex_unlock(&card->conf_mutex); 542 return rc; 543 } 544 545 static DEVICE_ATTR(isolation, 0644, qeth_dev_isolation_show, 546 qeth_dev_isolation_store); 547 548 static ssize_t qeth_dev_switch_attrs_show(struct device *dev, 549 struct device_attribute *attr, char *buf) 550 { 551 struct qeth_card *card = dev_get_drvdata(dev); 552 struct qeth_switch_info sw_info; 553 int rc = 0; 554 555 if (!card) 556 return -EINVAL; 557 558 if (card->state != CARD_STATE_SOFTSETUP && card->state != CARD_STATE_UP) 559 return sprintf(buf, "n/a\n"); 560 561 rc = qeth_query_switch_attributes(card, &sw_info); 562 if (rc) 563 return rc; 564 565 if (!sw_info.capabilities) 566 rc = sprintf(buf, "unknown"); 567 568 if (sw_info.capabilities & QETH_SWITCH_FORW_802_1) 569 rc = sprintf(buf, (sw_info.settings & QETH_SWITCH_FORW_802_1 ? 570 "[802.1]" : "802.1")); 571 if (sw_info.capabilities & QETH_SWITCH_FORW_REFL_RELAY) 572 rc += sprintf(buf + rc, 573 (sw_info.settings & QETH_SWITCH_FORW_REFL_RELAY ? 574 " [rr]" : " rr")); 575 rc += sprintf(buf + rc, "\n"); 576 577 return rc; 578 } 579 580 static DEVICE_ATTR(switch_attrs, 0444, 581 qeth_dev_switch_attrs_show, NULL); 582 583 static ssize_t qeth_hw_trap_show(struct device *dev, 584 struct device_attribute *attr, char *buf) 585 { 586 struct qeth_card *card = dev_get_drvdata(dev); 587 588 if (!card) 589 return -EINVAL; 590 if (card->info.hwtrap) 591 return snprintf(buf, 5, "arm\n"); 592 else 593 return snprintf(buf, 8, "disarm\n"); 594 } 595 596 static ssize_t qeth_hw_trap_store(struct device *dev, 597 struct device_attribute *attr, const char *buf, size_t count) 598 { 599 struct qeth_card *card = dev_get_drvdata(dev); 600 int rc = 0; 601 char *tmp, *curtoken; 602 int state = 0; 603 curtoken = (char *)buf; 604 605 if (!card) 606 return -EINVAL; 607 608 mutex_lock(&card->conf_mutex); 609 if (card->state == CARD_STATE_SOFTSETUP || card->state == CARD_STATE_UP) 610 state = 1; 611 tmp = strsep(&curtoken, "\n"); 612 613 if (!strcmp(tmp, "arm") && !card->info.hwtrap) { 614 if (state) { 615 if (qeth_is_diagass_supported(card, 616 QETH_DIAGS_CMD_TRAP)) { 617 rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_ARM); 618 if (!rc) 619 card->info.hwtrap = 1; 620 } else 621 rc = -EINVAL; 622 } else 623 card->info.hwtrap = 1; 624 } else if (!strcmp(tmp, "disarm") && card->info.hwtrap) { 625 if (state) { 626 rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); 627 if (!rc) 628 card->info.hwtrap = 0; 629 } else 630 card->info.hwtrap = 0; 631 } else if (!strcmp(tmp, "trap") && state && card->info.hwtrap) 632 rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_CAPTURE); 633 else 634 rc = -EINVAL; 635 636 mutex_unlock(&card->conf_mutex); 637 return rc ? rc : count; 638 } 639 640 static DEVICE_ATTR(hw_trap, 0644, qeth_hw_trap_show, 641 qeth_hw_trap_store); 642 643 static ssize_t qeth_dev_blkt_show(char *buf, struct qeth_card *card, int value) 644 { 645 646 if (!card) 647 return -EINVAL; 648 649 return sprintf(buf, "%i\n", value); 650 } 651 652 static ssize_t qeth_dev_blkt_store(struct qeth_card *card, 653 const char *buf, size_t count, int *value, int max_value) 654 { 655 char *tmp; 656 int i, rc = 0; 657 658 if (!card) 659 return -EINVAL; 660 661 mutex_lock(&card->conf_mutex); 662 if ((card->state != CARD_STATE_DOWN) && 663 (card->state != CARD_STATE_RECOVER)) { 664 rc = -EPERM; 665 goto out; 666 } 667 i = simple_strtoul(buf, &tmp, 10); 668 if (i <= max_value) 669 *value = i; 670 else 671 rc = -EINVAL; 672 out: 673 mutex_unlock(&card->conf_mutex); 674 return rc ? rc : count; 675 } 676 677 static ssize_t qeth_dev_blkt_total_show(struct device *dev, 678 struct device_attribute *attr, char *buf) 679 { 680 struct qeth_card *card = dev_get_drvdata(dev); 681 682 return qeth_dev_blkt_show(buf, card, card->info.blkt.time_total); 683 } 684 685 static ssize_t qeth_dev_blkt_total_store(struct device *dev, 686 struct device_attribute *attr, const char *buf, size_t count) 687 { 688 struct qeth_card *card = dev_get_drvdata(dev); 689 690 return qeth_dev_blkt_store(card, buf, count, 691 &card->info.blkt.time_total, 5000); 692 } 693 694 695 696 static DEVICE_ATTR(total, 0644, qeth_dev_blkt_total_show, 697 qeth_dev_blkt_total_store); 698 699 static ssize_t qeth_dev_blkt_inter_show(struct device *dev, 700 struct device_attribute *attr, char *buf) 701 { 702 struct qeth_card *card = dev_get_drvdata(dev); 703 704 return qeth_dev_blkt_show(buf, card, card->info.blkt.inter_packet); 705 } 706 707 static ssize_t qeth_dev_blkt_inter_store(struct device *dev, 708 struct device_attribute *attr, const char *buf, size_t count) 709 { 710 struct qeth_card *card = dev_get_drvdata(dev); 711 712 return qeth_dev_blkt_store(card, buf, count, 713 &card->info.blkt.inter_packet, 1000); 714 } 715 716 static DEVICE_ATTR(inter, 0644, qeth_dev_blkt_inter_show, 717 qeth_dev_blkt_inter_store); 718 719 static ssize_t qeth_dev_blkt_inter_jumbo_show(struct device *dev, 720 struct device_attribute *attr, char *buf) 721 { 722 struct qeth_card *card = dev_get_drvdata(dev); 723 724 return qeth_dev_blkt_show(buf, card, 725 card->info.blkt.inter_packet_jumbo); 726 } 727 728 static ssize_t qeth_dev_blkt_inter_jumbo_store(struct device *dev, 729 struct device_attribute *attr, const char *buf, size_t count) 730 { 731 struct qeth_card *card = dev_get_drvdata(dev); 732 733 return qeth_dev_blkt_store(card, buf, count, 734 &card->info.blkt.inter_packet_jumbo, 1000); 735 } 736 737 static DEVICE_ATTR(inter_jumbo, 0644, qeth_dev_blkt_inter_jumbo_show, 738 qeth_dev_blkt_inter_jumbo_store); 739 740 static struct attribute *qeth_blkt_device_attrs[] = { 741 &dev_attr_total.attr, 742 &dev_attr_inter.attr, 743 &dev_attr_inter_jumbo.attr, 744 NULL, 745 }; 746 static struct attribute_group qeth_device_blkt_group = { 747 .name = "blkt", 748 .attrs = qeth_blkt_device_attrs, 749 }; 750 751 static struct attribute *qeth_device_attrs[] = { 752 &dev_attr_state.attr, 753 &dev_attr_chpid.attr, 754 &dev_attr_if_name.attr, 755 &dev_attr_card_type.attr, 756 &dev_attr_inbuf_size.attr, 757 &dev_attr_portno.attr, 758 &dev_attr_portname.attr, 759 &dev_attr_priority_queueing.attr, 760 &dev_attr_buffer_count.attr, 761 &dev_attr_recover.attr, 762 &dev_attr_performance_stats.attr, 763 &dev_attr_layer2.attr, 764 &dev_attr_isolation.attr, 765 &dev_attr_hw_trap.attr, 766 &dev_attr_switch_attrs.attr, 767 NULL, 768 }; 769 static struct attribute_group qeth_device_attr_group = { 770 .attrs = qeth_device_attrs, 771 }; 772 773 const struct attribute_group *qeth_generic_attr_groups[] = { 774 &qeth_device_attr_group, 775 &qeth_device_blkt_group, 776 NULL, 777 }; 778 779 static struct attribute *qeth_osn_device_attrs[] = { 780 &dev_attr_state.attr, 781 &dev_attr_chpid.attr, 782 &dev_attr_if_name.attr, 783 &dev_attr_card_type.attr, 784 &dev_attr_buffer_count.attr, 785 &dev_attr_recover.attr, 786 NULL, 787 }; 788 static struct attribute_group qeth_osn_device_attr_group = { 789 .attrs = qeth_osn_device_attrs, 790 }; 791 const struct attribute_group *qeth_osn_attr_groups[] = { 792 &qeth_osn_device_attr_group, 793 NULL, 794 }; 795