^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Copyright(c) 2015-2017 Intel Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * This file is provided under a dual BSD/GPLv2 license. When using or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * redistributing this file, you may do so under either license.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * GPL LICENSE SUMMARY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * This program is free software; you can redistribute it and/or modify
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * it under the terms of version 2 of the GNU General Public License as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * published by the Free Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * This program is distributed in the hope that it will be useful, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * WITHOUT ANY WARRANTY; without even the implied warranty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * General Public License for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * BSD LICENSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * modification, are permitted provided that the following conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * are met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * - Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * notice, this list of conditions and the following disclaimer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * - Redistributions in binary form must reproduce the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * notice, this list of conditions and the following disclaimer in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * the documentation and/or other materials provided with the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * distribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * - Neither the name of Intel Corporation nor the names of its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * contributors may be used to endorse or promote products derived
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * from this software without specific prior written permission.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
^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) #include <linux/ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) #include "hfi.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #include "mad.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #include "trace.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * Start of per-port congestion control structures and support code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * Congestion control table size followed by table entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) static ssize_t read_cc_table_bin(struct file *filp, struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) struct bin_attribute *bin_attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) char *buf, loff_t pos, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) struct hfi1_pportdata *ppd =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) container_of(kobj, struct hfi1_pportdata, pport_cc_kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) struct cc_state *cc_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) ret = ppd->total_cct_entry * sizeof(struct ib_cc_table_entry_shadow)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) + sizeof(__be16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) if (pos > ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) if (count > ret - pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) count = ret - pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) if (!count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) cc_state = get_cc_state(ppd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) if (!cc_state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) memcpy(buf, (void *)&cc_state->cct + pos, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) static void port_release(struct kobject *kobj)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) /* nothing to do since memory is freed by hfi1_free_devdata() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) static const struct bin_attribute cc_table_bin_attr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) .attr = {.name = "cc_table_bin", .mode = 0444},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) .read = read_cc_table_bin,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) .size = PAGE_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) };
^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) * Congestion settings: port control, control map and an array of 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) * entries for the congestion entries - increase, timer, event log
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) * trigger threshold and the minimum injection rate delay.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) static ssize_t read_cc_setting_bin(struct file *filp, struct kobject *kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) struct bin_attribute *bin_attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) char *buf, loff_t pos, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) struct hfi1_pportdata *ppd =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) container_of(kobj, struct hfi1_pportdata, pport_cc_kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) struct cc_state *cc_state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) ret = sizeof(struct opa_congestion_setting_attr_shadow);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) if (pos > ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) if (count > ret - pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) count = ret - pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) if (!count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) rcu_read_lock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) cc_state = get_cc_state(ppd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) if (!cc_state) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) memcpy(buf, (void *)&cc_state->cong_setting + pos, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) rcu_read_unlock();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) return count;
^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 const struct bin_attribute cc_setting_bin_attr = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) .attr = {.name = "cc_settings_bin", .mode = 0444},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) .read = read_cc_setting_bin,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) .size = PAGE_SIZE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) struct hfi1_port_attr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) struct attribute attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) ssize_t (*show)(struct hfi1_pportdata *, char *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) ssize_t (*store)(struct hfi1_pportdata *, const char *, size_t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) static ssize_t cc_prescan_show(struct hfi1_pportdata *ppd, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) return sprintf(buf, "%s\n", ppd->cc_prescan ? "on" : "off");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) static ssize_t cc_prescan_store(struct hfi1_pportdata *ppd, const char *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) if (!memcmp(buf, "on", 2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) ppd->cc_prescan = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) else if (!memcmp(buf, "off", 3))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) ppd->cc_prescan = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) static struct hfi1_port_attr cc_prescan_attr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) __ATTR(cc_prescan, 0600, cc_prescan_show, cc_prescan_store);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) static ssize_t cc_attr_show(struct kobject *kobj, struct attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) struct hfi1_port_attr *port_attr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) container_of(attr, struct hfi1_port_attr, attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) struct hfi1_pportdata *ppd =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) container_of(kobj, struct hfi1_pportdata, pport_cc_kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) return port_attr->show(ppd, buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) static ssize_t cc_attr_store(struct kobject *kobj, struct attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) struct hfi1_port_attr *port_attr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) container_of(attr, struct hfi1_port_attr, attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) struct hfi1_pportdata *ppd =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) container_of(kobj, struct hfi1_pportdata, pport_cc_kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) return port_attr->store(ppd, buf, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) static const struct sysfs_ops port_cc_sysfs_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) .show = cc_attr_show,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) .store = cc_attr_store
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) static struct attribute *port_cc_default_attributes[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) &cc_prescan_attr.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) static struct kobj_type port_cc_ktype = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) .release = port_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) .sysfs_ops = &port_cc_sysfs_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) .default_attrs = port_cc_default_attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) /* Start sc2vl */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) #define HFI1_SC2VL_ATTR(N) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) static struct hfi1_sc2vl_attr hfi1_sc2vl_attr_##N = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) .attr = { .name = __stringify(N), .mode = 0444 }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) .sc = N \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) struct hfi1_sc2vl_attr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) struct attribute attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) int sc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) HFI1_SC2VL_ATTR(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) HFI1_SC2VL_ATTR(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) HFI1_SC2VL_ATTR(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) HFI1_SC2VL_ATTR(3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) HFI1_SC2VL_ATTR(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) HFI1_SC2VL_ATTR(5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) HFI1_SC2VL_ATTR(6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) HFI1_SC2VL_ATTR(7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) HFI1_SC2VL_ATTR(8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) HFI1_SC2VL_ATTR(9);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) HFI1_SC2VL_ATTR(10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) HFI1_SC2VL_ATTR(11);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) HFI1_SC2VL_ATTR(12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) HFI1_SC2VL_ATTR(13);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) HFI1_SC2VL_ATTR(14);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) HFI1_SC2VL_ATTR(15);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) HFI1_SC2VL_ATTR(16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) HFI1_SC2VL_ATTR(17);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) HFI1_SC2VL_ATTR(18);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) HFI1_SC2VL_ATTR(19);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) HFI1_SC2VL_ATTR(20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) HFI1_SC2VL_ATTR(21);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) HFI1_SC2VL_ATTR(22);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) HFI1_SC2VL_ATTR(23);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) HFI1_SC2VL_ATTR(24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) HFI1_SC2VL_ATTR(25);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) HFI1_SC2VL_ATTR(26);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) HFI1_SC2VL_ATTR(27);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) HFI1_SC2VL_ATTR(28);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) HFI1_SC2VL_ATTR(29);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) HFI1_SC2VL_ATTR(30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) HFI1_SC2VL_ATTR(31);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) static struct attribute *sc2vl_default_attributes[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) &hfi1_sc2vl_attr_0.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) &hfi1_sc2vl_attr_1.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) &hfi1_sc2vl_attr_2.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) &hfi1_sc2vl_attr_3.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) &hfi1_sc2vl_attr_4.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) &hfi1_sc2vl_attr_5.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) &hfi1_sc2vl_attr_6.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) &hfi1_sc2vl_attr_7.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) &hfi1_sc2vl_attr_8.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) &hfi1_sc2vl_attr_9.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) &hfi1_sc2vl_attr_10.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) &hfi1_sc2vl_attr_11.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) &hfi1_sc2vl_attr_12.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) &hfi1_sc2vl_attr_13.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) &hfi1_sc2vl_attr_14.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) &hfi1_sc2vl_attr_15.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) &hfi1_sc2vl_attr_16.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) &hfi1_sc2vl_attr_17.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) &hfi1_sc2vl_attr_18.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) &hfi1_sc2vl_attr_19.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) &hfi1_sc2vl_attr_20.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) &hfi1_sc2vl_attr_21.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) &hfi1_sc2vl_attr_22.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) &hfi1_sc2vl_attr_23.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) &hfi1_sc2vl_attr_24.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) &hfi1_sc2vl_attr_25.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) &hfi1_sc2vl_attr_26.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) &hfi1_sc2vl_attr_27.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) &hfi1_sc2vl_attr_28.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) &hfi1_sc2vl_attr_29.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) &hfi1_sc2vl_attr_30.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) &hfi1_sc2vl_attr_31.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) static ssize_t sc2vl_attr_show(struct kobject *kobj, struct attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) struct hfi1_sc2vl_attr *sattr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) container_of(attr, struct hfi1_sc2vl_attr, attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) struct hfi1_pportdata *ppd =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) container_of(kobj, struct hfi1_pportdata, sc2vl_kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) struct hfi1_devdata *dd = ppd->dd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) return sprintf(buf, "%u\n", *((u8 *)dd->sc2vl + sattr->sc));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) static const struct sysfs_ops hfi1_sc2vl_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) .show = sc2vl_attr_show,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) static struct kobj_type hfi1_sc2vl_ktype = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) .release = port_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) .sysfs_ops = &hfi1_sc2vl_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) .default_attrs = sc2vl_default_attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) /* End sc2vl */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) /* Start sl2sc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) #define HFI1_SL2SC_ATTR(N) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) static struct hfi1_sl2sc_attr hfi1_sl2sc_attr_##N = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) .attr = { .name = __stringify(N), .mode = 0444 }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) .sl = N \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) struct hfi1_sl2sc_attr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) struct attribute attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) int sl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) HFI1_SL2SC_ATTR(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) HFI1_SL2SC_ATTR(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) HFI1_SL2SC_ATTR(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) HFI1_SL2SC_ATTR(3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) HFI1_SL2SC_ATTR(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) HFI1_SL2SC_ATTR(5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) HFI1_SL2SC_ATTR(6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) HFI1_SL2SC_ATTR(7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) HFI1_SL2SC_ATTR(8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) HFI1_SL2SC_ATTR(9);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) HFI1_SL2SC_ATTR(10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) HFI1_SL2SC_ATTR(11);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) HFI1_SL2SC_ATTR(12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) HFI1_SL2SC_ATTR(13);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) HFI1_SL2SC_ATTR(14);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) HFI1_SL2SC_ATTR(15);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) HFI1_SL2SC_ATTR(16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) HFI1_SL2SC_ATTR(17);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) HFI1_SL2SC_ATTR(18);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) HFI1_SL2SC_ATTR(19);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) HFI1_SL2SC_ATTR(20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) HFI1_SL2SC_ATTR(21);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) HFI1_SL2SC_ATTR(22);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) HFI1_SL2SC_ATTR(23);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) HFI1_SL2SC_ATTR(24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) HFI1_SL2SC_ATTR(25);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) HFI1_SL2SC_ATTR(26);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) HFI1_SL2SC_ATTR(27);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) HFI1_SL2SC_ATTR(28);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) HFI1_SL2SC_ATTR(29);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) HFI1_SL2SC_ATTR(30);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) HFI1_SL2SC_ATTR(31);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) static struct attribute *sl2sc_default_attributes[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) &hfi1_sl2sc_attr_0.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) &hfi1_sl2sc_attr_1.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) &hfi1_sl2sc_attr_2.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) &hfi1_sl2sc_attr_3.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) &hfi1_sl2sc_attr_4.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) &hfi1_sl2sc_attr_5.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) &hfi1_sl2sc_attr_6.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) &hfi1_sl2sc_attr_7.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) &hfi1_sl2sc_attr_8.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) &hfi1_sl2sc_attr_9.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) &hfi1_sl2sc_attr_10.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) &hfi1_sl2sc_attr_11.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) &hfi1_sl2sc_attr_12.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) &hfi1_sl2sc_attr_13.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) &hfi1_sl2sc_attr_14.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) &hfi1_sl2sc_attr_15.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) &hfi1_sl2sc_attr_16.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) &hfi1_sl2sc_attr_17.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) &hfi1_sl2sc_attr_18.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) &hfi1_sl2sc_attr_19.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) &hfi1_sl2sc_attr_20.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) &hfi1_sl2sc_attr_21.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) &hfi1_sl2sc_attr_22.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) &hfi1_sl2sc_attr_23.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) &hfi1_sl2sc_attr_24.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) &hfi1_sl2sc_attr_25.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) &hfi1_sl2sc_attr_26.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) &hfi1_sl2sc_attr_27.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) &hfi1_sl2sc_attr_28.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) &hfi1_sl2sc_attr_29.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) &hfi1_sl2sc_attr_30.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) &hfi1_sl2sc_attr_31.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) static ssize_t sl2sc_attr_show(struct kobject *kobj, struct attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) struct hfi1_sl2sc_attr *sattr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) container_of(attr, struct hfi1_sl2sc_attr, attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) struct hfi1_pportdata *ppd =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) container_of(kobj, struct hfi1_pportdata, sl2sc_kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) struct hfi1_ibport *ibp = &ppd->ibport_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) return sprintf(buf, "%u\n", ibp->sl_to_sc[sattr->sl]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) static const struct sysfs_ops hfi1_sl2sc_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) .show = sl2sc_attr_show,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) static struct kobj_type hfi1_sl2sc_ktype = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) .release = port_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) .sysfs_ops = &hfi1_sl2sc_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) .default_attrs = sl2sc_default_attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) /* End sl2sc */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) /* Start vl2mtu */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) #define HFI1_VL2MTU_ATTR(N) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) static struct hfi1_vl2mtu_attr hfi1_vl2mtu_attr_##N = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) .attr = { .name = __stringify(N), .mode = 0444 }, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) .vl = N \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) struct hfi1_vl2mtu_attr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) struct attribute attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) int vl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) HFI1_VL2MTU_ATTR(0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) HFI1_VL2MTU_ATTR(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) HFI1_VL2MTU_ATTR(2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) HFI1_VL2MTU_ATTR(3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) HFI1_VL2MTU_ATTR(4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) HFI1_VL2MTU_ATTR(5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) HFI1_VL2MTU_ATTR(6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) HFI1_VL2MTU_ATTR(7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) HFI1_VL2MTU_ATTR(8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) HFI1_VL2MTU_ATTR(9);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) HFI1_VL2MTU_ATTR(10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) HFI1_VL2MTU_ATTR(11);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) HFI1_VL2MTU_ATTR(12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) HFI1_VL2MTU_ATTR(13);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) HFI1_VL2MTU_ATTR(14);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) HFI1_VL2MTU_ATTR(15);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) static struct attribute *vl2mtu_default_attributes[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) &hfi1_vl2mtu_attr_0.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) &hfi1_vl2mtu_attr_1.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) &hfi1_vl2mtu_attr_2.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) &hfi1_vl2mtu_attr_3.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) &hfi1_vl2mtu_attr_4.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) &hfi1_vl2mtu_attr_5.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) &hfi1_vl2mtu_attr_6.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) &hfi1_vl2mtu_attr_7.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) &hfi1_vl2mtu_attr_8.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) &hfi1_vl2mtu_attr_9.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) &hfi1_vl2mtu_attr_10.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) &hfi1_vl2mtu_attr_11.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) &hfi1_vl2mtu_attr_12.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) &hfi1_vl2mtu_attr_13.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) &hfi1_vl2mtu_attr_14.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) &hfi1_vl2mtu_attr_15.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) NULL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) static ssize_t vl2mtu_attr_show(struct kobject *kobj, struct attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) struct hfi1_vl2mtu_attr *vlattr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) container_of(attr, struct hfi1_vl2mtu_attr, attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) struct hfi1_pportdata *ppd =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) container_of(kobj, struct hfi1_pportdata, vl2mtu_kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) struct hfi1_devdata *dd = ppd->dd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) return sprintf(buf, "%u\n", dd->vld[vlattr->vl].mtu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) static const struct sysfs_ops hfi1_vl2mtu_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) .show = vl2mtu_attr_show,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) static struct kobj_type hfi1_vl2mtu_ktype = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) .release = port_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) .sysfs_ops = &hfi1_vl2mtu_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) .default_attrs = vl2mtu_default_attributes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) /* end of per-port file structures and support code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) * Start of per-unit (or driver, in some cases, but replicated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) * per unit) functions (these get a device *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) static ssize_t hw_rev_show(struct device *device, struct device_attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) struct hfi1_ibdev *dev =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) return sprintf(buf, "%x\n", dd_from_dev(dev)->minrev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) static DEVICE_ATTR_RO(hw_rev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) static ssize_t board_id_show(struct device *device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) struct hfi1_ibdev *dev =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) struct hfi1_devdata *dd = dd_from_dev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) if (!dd->boardname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) ret = scnprintf(buf, PAGE_SIZE, "%s\n", dd->boardname);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) static DEVICE_ATTR_RO(board_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) static ssize_t boardversion_show(struct device *device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) struct hfi1_ibdev *dev =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) struct hfi1_devdata *dd = dd_from_dev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) /* The string printed here is already newline-terminated. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) return scnprintf(buf, PAGE_SIZE, "%s", dd->boardversion);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) static DEVICE_ATTR_RO(boardversion);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) static ssize_t nctxts_show(struct device *device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) struct hfi1_ibdev *dev =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) struct hfi1_devdata *dd = dd_from_dev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) * Return the smaller of send and receive contexts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) * Normally, user level applications would require both a send
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) * and a receive context, so returning the smaller of the two counts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) * give a more accurate picture of total contexts available.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) return scnprintf(buf, PAGE_SIZE, "%u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) min(dd->num_user_contexts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) (u32)dd->sc_sizes[SC_USER].count));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) static DEVICE_ATTR_RO(nctxts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) static ssize_t nfreectxts_show(struct device *device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) struct hfi1_ibdev *dev =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) struct hfi1_devdata *dd = dd_from_dev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) /* Return the number of free user ports (contexts) available. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) return scnprintf(buf, PAGE_SIZE, "%u\n", dd->freectxts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) static DEVICE_ATTR_RO(nfreectxts);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) static ssize_t serial_show(struct device *device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) struct hfi1_ibdev *dev =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) struct hfi1_devdata *dd = dd_from_dev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) return scnprintf(buf, PAGE_SIZE, "%s", dd->serial);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) static DEVICE_ATTR_RO(serial);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) static ssize_t chip_reset_store(struct device *device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) struct device_attribute *attr, const char *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) struct hfi1_ibdev *dev =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) struct hfi1_devdata *dd = dd_from_dev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) if (count < 5 || memcmp(buf, "reset", 5) || !dd->diag_client) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) ret = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) ret = hfi1_reset_device(dd->unit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) bail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) return ret < 0 ? ret : count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) static DEVICE_ATTR_WO(chip_reset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) * Convert the reported temperature from an integer (reported in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) * units of 0.25C) to a floating point number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) #define temp2str(temp, buf, size, idx) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) scnprintf((buf) + (idx), (size) - (idx), "%u.%02u ", \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) ((temp) >> 2), ((temp) & 0x3) * 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) * Dump tempsense values, in decimal, to ease shell-scripts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) static ssize_t tempsense_show(struct device *device,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) struct device_attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) struct hfi1_ibdev *dev =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) rdma_device_to_drv_device(device, struct hfi1_ibdev, rdi.ibdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) struct hfi1_devdata *dd = dd_from_dev(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) struct hfi1_temp temp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) ret = hfi1_tempsense_rd(dd, &temp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) if (!ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) int idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) idx += temp2str(temp.curr, buf, PAGE_SIZE, idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) idx += temp2str(temp.lo_lim, buf, PAGE_SIZE, idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) idx += temp2str(temp.hi_lim, buf, PAGE_SIZE, idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) idx += temp2str(temp.crit_lim, buf, PAGE_SIZE, idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) idx += scnprintf(buf + idx, PAGE_SIZE - idx,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) "%u %u %u\n", temp.triggers & 0x1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) temp.triggers & 0x2, temp.triggers & 0x4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) ret = idx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) static DEVICE_ATTR_RO(tempsense);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) * end of per-unit (or driver, in some cases, but replicated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) * per unit) functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) /* start of per-unit file structures and support code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) static struct attribute *hfi1_attributes[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) &dev_attr_hw_rev.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) &dev_attr_board_id.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) &dev_attr_nctxts.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) &dev_attr_nfreectxts.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) &dev_attr_serial.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) &dev_attr_boardversion.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) &dev_attr_tempsense.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) &dev_attr_chip_reset.attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) const struct attribute_group ib_hfi1_attr_group = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) .attrs = hfi1_attributes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) int hfi1_create_port_files(struct ib_device *ibdev, u8 port_num,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) struct kobject *kobj)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) struct hfi1_pportdata *ppd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) struct hfi1_devdata *dd = dd_from_ibdev(ibdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) if (!port_num || port_num > dd->num_pports) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) dd_dev_err(dd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) "Skipping infiniband class with invalid port %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) ppd = &dd->pport[port_num - 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) ret = kobject_init_and_add(&ppd->sc2vl_kobj, &hfi1_sc2vl_ktype, kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) "sc2vl");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) dd_dev_err(dd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) "Skipping sc2vl sysfs info, (err %d) port %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) ret, port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) * Based on the documentation for kobject_init_and_add(), the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) * caller should call kobject_put even if this call fails.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) goto bail_sc2vl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) kobject_uevent(&ppd->sc2vl_kobj, KOBJ_ADD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) ret = kobject_init_and_add(&ppd->sl2sc_kobj, &hfi1_sl2sc_ktype, kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) "sl2sc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) dd_dev_err(dd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) "Skipping sl2sc sysfs info, (err %d) port %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) ret, port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) goto bail_sl2sc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) kobject_uevent(&ppd->sl2sc_kobj, KOBJ_ADD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) ret = kobject_init_and_add(&ppd->vl2mtu_kobj, &hfi1_vl2mtu_ktype, kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) "vl2mtu");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) dd_dev_err(dd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) "Skipping vl2mtu sysfs info, (err %d) port %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) ret, port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) goto bail_vl2mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) kobject_uevent(&ppd->vl2mtu_kobj, KOBJ_ADD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) ret = kobject_init_and_add(&ppd->pport_cc_kobj, &port_cc_ktype,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) kobj, "CCMgtA");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) dd_dev_err(dd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) "Skipping Congestion Control sysfs info, (err %d) port %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) ret, port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) goto bail_cc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) kobject_uevent(&ppd->pport_cc_kobj, KOBJ_ADD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) ret = sysfs_create_bin_file(&ppd->pport_cc_kobj, &cc_setting_bin_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) dd_dev_err(dd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) "Skipping Congestion Control setting sysfs info, (err %d) port %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) ret, port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) goto bail_cc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) ret = sysfs_create_bin_file(&ppd->pport_cc_kobj, &cc_table_bin_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) dd_dev_err(dd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) "Skipping Congestion Control table sysfs info, (err %d) port %u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) ret, port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) goto bail_cc_entry_bin;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) dd_dev_info(dd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) "Congestion Control Agent enabled for port %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) port_num);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) bail_cc_entry_bin:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) sysfs_remove_bin_file(&ppd->pport_cc_kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) &cc_setting_bin_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) bail_cc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) kobject_put(&ppd->pport_cc_kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) bail_vl2mtu:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) kobject_put(&ppd->vl2mtu_kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) bail_sl2sc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) kobject_put(&ppd->sl2sc_kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) bail_sc2vl:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) kobject_put(&ppd->sc2vl_kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) struct sde_attribute {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) struct attribute attr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) ssize_t (*show)(struct sdma_engine *sde, char *buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) ssize_t (*store)(struct sdma_engine *sde, const char *buf, size_t cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) static ssize_t sde_show(struct kobject *kobj, struct attribute *attr, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) struct sde_attribute *sde_attr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) container_of(attr, struct sde_attribute, attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) struct sdma_engine *sde =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) container_of(kobj, struct sdma_engine, kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) if (!sde_attr->show)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) return sde_attr->show(sde, buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) static ssize_t sde_store(struct kobject *kobj, struct attribute *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) struct sde_attribute *sde_attr =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) container_of(attr, struct sde_attribute, attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) struct sdma_engine *sde =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) container_of(kobj, struct sdma_engine, kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) if (!capable(CAP_SYS_ADMIN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) return -EPERM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) if (!sde_attr->store)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) return sde_attr->store(sde, buf, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) static const struct sysfs_ops sde_sysfs_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) .show = sde_show,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) .store = sde_store,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) static struct kobj_type sde_ktype = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) .sysfs_ops = &sde_sysfs_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) #define SDE_ATTR(_name, _mode, _show, _store) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) struct sde_attribute sde_attr_##_name = \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) __ATTR(_name, _mode, _show, _store)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) static ssize_t sde_show_cpu_to_sde_map(struct sdma_engine *sde, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) return sdma_get_cpu_to_sde_map(sde, buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) static ssize_t sde_store_cpu_to_sde_map(struct sdma_engine *sde,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) const char *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) return sdma_set_cpu_to_sde_map(sde, buf, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) static ssize_t sde_show_vl(struct sdma_engine *sde, char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) int vl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) vl = sdma_engine_get_vl(sde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) if (vl < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) return vl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) return snprintf(buf, PAGE_SIZE, "%d\n", vl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) static SDE_ATTR(cpu_list, S_IWUSR | S_IRUGO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) sde_show_cpu_to_sde_map,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) sde_store_cpu_to_sde_map);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) static SDE_ATTR(vl, S_IRUGO, sde_show_vl, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) static struct sde_attribute *sde_attribs[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) &sde_attr_cpu_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) &sde_attr_vl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) * Register and create our files in /sys/class/infiniband.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) int hfi1_verbs_register_sysfs(struct hfi1_devdata *dd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) struct ib_device *dev = &dd->verbs_dev.rdi.ibdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) struct device *class_dev = &dev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) int i, j, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) for (i = 0; i < dd->num_sdma; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) ret = kobject_init_and_add(&dd->per_sdma[i].kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) &sde_ktype, &class_dev->kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) "sdma%d", i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) for (j = 0; j < ARRAY_SIZE(sde_attribs); j++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) ret = sysfs_create_file(&dd->per_sdma[i].kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) &sde_attribs[j]->attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) goto bail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) bail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) * The function kobject_put() will call kobject_del() if the kobject
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) * has been added successfully. The sysfs files created under the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) * kobject directory will also be removed during the process.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) for (; i >= 0; i--)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) kobject_put(&dd->per_sdma[i].kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) * Unregister and remove our files in /sys/class/infiniband.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) void hfi1_verbs_unregister_sysfs(struct hfi1_devdata *dd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) struct hfi1_pportdata *ppd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) /* Unwind operations in hfi1_verbs_register_sysfs() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) for (i = 0; i < dd->num_sdma; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) kobject_put(&dd->per_sdma[i].kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) for (i = 0; i < dd->num_pports; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) ppd = &dd->pport[i];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) sysfs_remove_bin_file(&ppd->pport_cc_kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) &cc_setting_bin_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) sysfs_remove_bin_file(&ppd->pport_cc_kobj,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) &cc_table_bin_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) kobject_put(&ppd->pport_cc_kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) kobject_put(&ppd->vl2mtu_kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) kobject_put(&ppd->sl2sc_kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) kobject_put(&ppd->sc2vl_kobj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) }