^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* bnx2i_sysfs.c: QLogic NetXtreme II iSCSI driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2004 - 2013 Broadcom Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 2014, QLogic Corporation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * This program is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * it under the terms of the GNU General Public License as published by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * the Free Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Written by: Anil Veerabhadrappa (anilgv@broadcom.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Previously Maintained by: Eddie Wai (eddie.wai@broadcom.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Maintained by: QLogic-Storage-Upstream@qlogic.com
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "bnx2i.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * bnx2i_dev_to_hba - maps dev pointer to adapter struct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * @dev: device pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * Map device to hba structure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) static inline struct bnx2i_hba *bnx2i_dev_to_hba(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct Scsi_Host *shost = class_to_shost(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) return iscsi_host_priv(shost);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * bnx2i_show_sq_info - return(s currently configured send queue (SQ) size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * @dev: device pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * @attr: device attribute (unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * @buf: buffer to return current SQ size parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * Returns current SQ size parameter, this paramater determines the number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * outstanding iSCSI commands supported on a connection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static ssize_t bnx2i_show_sq_info(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) return sprintf(buf, "0x%x\n", hba->max_sqes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * bnx2i_set_sq_info - update send queue (SQ) size parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * @dev: device pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * @attr: device attribute (unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * @buf: buffer to return current SQ size parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * @count: parameter buffer size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * Interface for user to change shared queue size allocated for each conn
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * Must be within SQ limits and a power of 2. For the latter this is needed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * because of how libiscsi preallocates tasks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static ssize_t bnx2i_set_sq_info(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) u32 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) int max_sq_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) if (hba->ofld_conns_active)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) goto skip_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) if (test_bit(BNX2I_NX2_DEV_57710, &hba->cnic_dev_type))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) max_sq_size = BNX2I_5770X_SQ_WQES_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) max_sq_size = BNX2I_570X_SQ_WQES_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) if (sscanf(buf, " 0x%x ", &val) > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) if ((val >= BNX2I_SQ_WQES_MIN) && (val <= max_sq_size) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) (is_power_of_2(val)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) hba->max_sqes = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) skip_config:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) printk(KERN_ERR "bnx2i: device busy, cannot change SQ size\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * bnx2i_show_ccell_info - returns command cell (HQ) size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * @dev: device pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * @attr: device attribute (unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) * @buf: buffer to return current SQ size parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * returns per-connection TCP history queue size parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) static ssize_t bnx2i_show_ccell_info(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) return sprintf(buf, "0x%x\n", hba->num_ccell);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * bnx2i_get_link_state - set command cell (HQ) size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) * @dev: device pointer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * @attr: device attribute (unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) * @buf: buffer to return current SQ size parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * @count: parameter buffer size
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * updates per-connection TCP history queue size parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static ssize_t bnx2i_set_ccell_info(struct device *dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) u32 val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) struct bnx2i_hba *hba = bnx2i_dev_to_hba(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) if (hba->ofld_conns_active)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) goto skip_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) if (sscanf(buf, " 0x%x ", &val) > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) if ((val >= BNX2I_CCELLS_MIN) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) (val <= BNX2I_CCELLS_MAX)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) hba->num_ccell = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) skip_config:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) printk(KERN_ERR "bnx2i: device busy, cannot change CCELL size\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) static DEVICE_ATTR(sq_size, S_IRUGO | S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) bnx2i_show_sq_info, bnx2i_set_sq_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) static DEVICE_ATTR(num_ccell, S_IRUGO | S_IWUSR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) bnx2i_show_ccell_info, bnx2i_set_ccell_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) struct device_attribute *bnx2i_dev_attributes[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) &dev_attr_sq_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) &dev_attr_num_ccell,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) };