^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Copyright (c) 2000-2001 Adaptec Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * modification, are permitted provided that the following conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * are met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * 1. Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * notice, this list of conditions, and the following disclaimer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * without modification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * 2. Redistributions in binary form must reproduce at minimum a disclaimer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * substantially similar to the "NO WARRANTY" disclaimer below
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * ("Disclaimer") and any redistribution must be conditioned upon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * including a substantially similar Disclaimer requirement for further
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * binary redistribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * 3. Neither the names of the above-listed copyright holders nor the names
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * of any contributors may be used to endorse or promote products derived
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * from this software without specific prior written permission.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * Alternatively, this software may be distributed under the terms of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * GNU General Public License ("GPL") version 2 as published by the Free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * NO WARRANTY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * POSSIBILITY OF SUCH DAMAGES.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) * String handling code courtesy of Gerard Roudier's <groudier@club-internet.fr>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * sym driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic79xx_proc.c#19 $
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #include "aic79xx_osm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #include "aic79xx_inline.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) static void ahd_dump_target_state(struct ahd_softc *ahd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) struct seq_file *m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) u_int our_id, char channel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) u_int target_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) static void ahd_dump_device_state(struct seq_file *m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) struct scsi_device *sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * Table of syncrates that don't follow the "divisible by 4"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * rule. This table will be expanded in future SCSI specs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) static const struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) u_int period_factor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) u_int period; /* in 100ths of ns */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) } scsi_syncrates[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) { 0x08, 625 }, /* FAST-160 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) { 0x09, 1250 }, /* FAST-80 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) { 0x0a, 2500 }, /* FAST-40 40MHz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) { 0x0b, 3030 }, /* FAST-40 33MHz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) { 0x0c, 5000 } /* FAST-20 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * Return the frequency in kHz corresponding to the given
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * sync period factor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) static u_int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) ahd_calc_syncsrate(u_int period_factor)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) /* See if the period is in the "exception" table */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) for (i = 0; i < ARRAY_SIZE(scsi_syncrates); i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) if (period_factor == scsi_syncrates[i].period_factor) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) /* Period in kHz */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) return (100000000 / scsi_syncrates[i].period);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) * Wasn't in the table, so use the standard
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * 4 times conversion.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) return (10000000 / (period_factor * 4 * 10));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) ahd_format_transinfo(struct seq_file *m, struct ahd_transinfo *tinfo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) u_int speed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) u_int freq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) u_int mb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) if (tinfo->period == AHD_PERIOD_UNKNOWN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) seq_puts(m, "Renegotiation Pending\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) speed = 3300;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) freq = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) if (tinfo->offset != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) freq = ahd_calc_syncsrate(tinfo->period);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) speed = freq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) speed *= (0x01 << tinfo->width);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) mb = speed / 1000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) if (mb > 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) seq_printf(m, "%d.%03dMB/s transfers", mb, speed % 1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) seq_printf(m, "%dKB/s transfers", speed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) if (freq != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) int printed_options;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) printed_options = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) seq_printf(m, " (%d.%03dMHz", freq / 1000, freq % 1000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) if ((tinfo->ppr_options & MSG_EXT_PPR_RD_STRM) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) seq_puts(m, " RDSTRM");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) printed_options++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) if ((tinfo->ppr_options & MSG_EXT_PPR_DT_REQ) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) seq_puts(m, printed_options ? "|DT" : " DT");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) printed_options++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) if ((tinfo->ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) seq_puts(m, printed_options ? "|IU" : " IU");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) printed_options++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) if ((tinfo->ppr_options & MSG_EXT_PPR_RTI) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) seq_puts(m, printed_options ? "|RTI" : " RTI");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) printed_options++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) if ((tinfo->ppr_options & MSG_EXT_PPR_QAS_REQ) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) seq_puts(m, printed_options ? "|QAS" : " QAS");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) printed_options++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) if (tinfo->width > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) if (freq != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) seq_puts(m, ", ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) seq_puts(m, " (");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) seq_printf(m, "%dbit)", 8 * (0x01 << tinfo->width));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) } else if (freq != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) seq_putc(m, ')');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) ahd_dump_target_state(struct ahd_softc *ahd, struct seq_file *m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) u_int our_id, char channel, u_int target_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) struct scsi_target *starget;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) struct ahd_initiator_tinfo *tinfo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) struct ahd_tmode_tstate *tstate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) int lun;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) tinfo = ahd_fetch_transinfo(ahd, channel, our_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) target_id, &tstate);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) seq_printf(m, "Target %d Negotiation Settings\n", target_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) seq_puts(m, "\tUser: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) ahd_format_transinfo(m, &tinfo->user);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) starget = ahd->platform_data->starget[target_id];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) if (starget == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) seq_puts(m, "\tGoal: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) ahd_format_transinfo(m, &tinfo->goal);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) seq_puts(m, "\tCurr: ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) ahd_format_transinfo(m, &tinfo->curr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) for (lun = 0; lun < AHD_NUM_LUNS; lun++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) struct scsi_device *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) dev = scsi_device_lookup_by_target(starget, lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) if (dev == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) ahd_dump_device_state(m, dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) static void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) ahd_dump_device_state(struct seq_file *m, struct scsi_device *sdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) struct ahd_linux_device *dev = scsi_transport_device_data(sdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) seq_printf(m, "\tChannel %c Target %d Lun %d Settings\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) sdev->sdev_target->channel + 'A',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) sdev->sdev_target->id, (u8)sdev->lun);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) seq_printf(m, "\t\tCommands Queued %ld\n", dev->commands_issued);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) seq_printf(m, "\t\tCommands Active %d\n", dev->active);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) seq_printf(m, "\t\tCommand Openings %d\n", dev->openings);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) seq_printf(m, "\t\tMax Tagged Openings %d\n", dev->maxtags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) seq_printf(m, "\t\tDevice Queue Frozen Count %d\n", dev->qfrozen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) ahd_proc_write_seeprom(struct Scsi_Host *shost, char *buffer, int length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct ahd_softc *ahd = *(struct ahd_softc **)shost->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) ahd_mode_state saved_modes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) int have_seeprom;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) u_long s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) int paused;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) int written;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) /* Default to failure. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) written = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) ahd_lock(ahd, &s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) paused = ahd_is_paused(ahd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) if (!paused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) ahd_pause(ahd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) saved_modes = ahd_save_modes(ahd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) ahd_set_modes(ahd, AHD_MODE_SCSI, AHD_MODE_SCSI);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) if (length != sizeof(struct seeprom_config)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) printk("ahd_proc_write_seeprom: incorrect buffer size\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) have_seeprom = ahd_verify_cksum((struct seeprom_config*)buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) if (have_seeprom == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) printk("ahd_proc_write_seeprom: cksum verification failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) have_seeprom = ahd_acquire_seeprom(ahd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) if (!have_seeprom) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) printk("ahd_proc_write_seeprom: No Serial EEPROM\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) u_int start_addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) if (ahd->seep_config == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) ahd->seep_config = kmalloc(sizeof(*ahd->seep_config), GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) if (ahd->seep_config == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) printk("aic79xx: Unable to allocate serial "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) "eeprom buffer. Write failing\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) goto done;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) printk("aic79xx: Writing Serial EEPROM\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) start_addr = 32 * (ahd->channel - 'A');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) ahd_write_seeprom(ahd, (u_int16_t *)buffer, start_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) sizeof(struct seeprom_config)/2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) ahd_read_seeprom(ahd, (uint16_t *)ahd->seep_config,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) start_addr, sizeof(struct seeprom_config)/2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) /*ByteStream*/FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) ahd_release_seeprom(ahd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) written = length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) done:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) ahd_restore_modes(ahd, saved_modes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) if (!paused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) ahd_unpause(ahd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) ahd_unlock(ahd, &s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) return (written);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) * Return information to handle /proc support for the driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) ahd_linux_show_info(struct seq_file *m, struct Scsi_Host *shost)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) struct ahd_softc *ahd = *(struct ahd_softc **)shost->hostdata;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) char ahd_info[256];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) u_int max_targ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) u_int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) seq_printf(m, "Adaptec AIC79xx driver version: %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) AIC79XX_DRIVER_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) seq_printf(m, "%s\n", ahd->description);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) ahd_controller_info(ahd, ahd_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) seq_printf(m, "%s\n", ahd_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) seq_printf(m, "Allocated SCBs: %d, SG List Length: %d\n\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) ahd->scb_data.numscbs, AHD_NSEG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) max_targ = 16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) if (ahd->seep_config == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) seq_puts(m, "No Serial EEPROM\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) seq_puts(m, "Serial EEPROM:\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) for (i = 0; i < sizeof(*ahd->seep_config)/2; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) if (((i % 8) == 0) && (i != 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) seq_printf(m, "0x%.4x ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) ((uint16_t*)ahd->seep_config)[i]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) seq_putc(m, '\n');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) if ((ahd->features & AHD_WIDE) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) max_targ = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) for (i = 0; i < max_targ; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) ahd_dump_target_state(ahd, m, ahd->our_id, 'A',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) /*target_id*/i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) }