Messages in this thread | | | Subject | Re: [PATCH] Add iSCSI IBFT Support (v0.3) | Date | Mon, 26 Nov 2007 22:12:53 -0600 | From | Doug Maxey <> |
| |
On Mon, 26 Nov 2007 19:31:38 PST, Greg KH wrote: > On Mon, Nov 26, 2007 at 06:56:42PM -0400, Konrad Rzeszutek wrote: > > +/* > > + * Routines for reading of the iBFT data in a human readable fashion. > > + */ > > +ssize_t ibft_attr_show_initiator(struct ibft_kobject *entry, > > + struct ibft_attribute *attr, > > + char *buf) > > +{ > > + struct ibft_initiator *initiator = attr->initiator; > > + void *ibft_loc = entry->data->hdr; > > + char *str = buf; > > + > > + if (!initiator) > > + return 0; > > + > > + str += sprintf_ipaddr(str, "isns", initiator->isns_server); > > + str += sprintf_ipaddr(str, "slp", initiator->slp_server); > > + str += sprintf_ipaddr(str, "primary_radius_server", > > + initiator->pri_radius_server); > > + str += sprintf_ipaddr(str, "secondary_radius_server", > > + initiator->sec_radius_server); > > + str += sprintf_string(str, "itname", initiator->initiator_name_len, > > + (char *)ibft_loc + initiator->initiator_name_off); > > + str--; > > + > > + return str-buf; > > +} > > sysfs files have ONE VALUE PER FILE, not a whole bunch of different > things in a single file. Please fix this.
The subparameters _are_ actually part of a single value, that value being associated with the initiator instance.
Konrad is trying to implement a "work-alike" for what open firmware does. open-iscsi already has the ability to extract the same format bits from real OFW.
See open-iscsi.git/utils/fwparam_ppc.
> > > > + > > +ssize_t ibft_attr_show_nic(struct ibft_kobject *entry, > > + struct ibft_attribute *attr, > > + char *buf) > > +{ > > + struct ibft_nic *nic = attr->nic; > > + void *ibft_loc = entry->data->hdr; > > + char *str = buf; > > + > > + if (!nic) > > + return 0; > > + /* > > + * Assume dhcp if any non-zero portions of its address are set. > > + */ > > + if (memcmp(nic->dhcp, nulls, sizeof(nic->dhcp))) { > > + str += sprintf_ipaddr(str, "dhcp", nic->dhcp); > > + } else { > > + str += sprintf_ipaddr(str, "ciaddr", nic->ip_addr); > > + str += sprintf_ipaddr(str, "giaddr", nic->gateway); > > + str += sprintf_ipaddr(str, "dnsaddr1", nic->primary_dns); > > + str += sprintf_ipaddr(str, "dnsaddr2", nic->secondary_dns); > > + } > > + if (nic->hostname_len) > > + str += sprintf_string(str, "hostname", nic->hostname_len, > > + (char *)ibft_loc + nic->hostname_off); > > + /* Cut off the comma. */ > > + str--; > > + > > + return str-buf; > > +} > > Same here. > > > +ssize_t ibft_attr_show_target(struct ibft_kobject *entry, > > + struct ibft_attribute *attr, > > + char *buf) > > +{ > > + struct ibft_tgt *tgt = attr->tgt; > > + void *ibft_loc = entry->data->hdr; > > + char *str = buf; > > + int i; > > + > > + if (!tgt) > > + return 0; > > + > > + str += sprintf_ipaddr(str, "siaddr", tgt->ip_addr); > > + str += sprintf(str, "iport=%d,", tgt->port); > > + str += sprintf(str, "ilun="); > > + for (i = 0; i < 8; i++) > > + str += sprintf(str, "%x", (u8)tgt->lun[i]); > > + str += sprintf(str, ","); > > + > > + if (tgt->tgt_name_len) > > + str += sprintf_string(str, "iname", tgt->tgt_name_len, > > + (void *)ibft_loc + tgt->tgt_name_off); > > + > > + if (tgt->chap_name_len) > > + str += sprintf_string(str, "chapid", tgt->chap_name_len, > > + (char *)ibft_loc + tgt->chap_name_off); > > + if (tgt->chap_secret_len) > > + str += sprintf_string(str, "chappw", tgt->chap_secret_len, > > + (char *)ibft_loc + tgt->chap_secret_off); > > + if (tgt->rev_chap_name_len) > > + str += sprintf_string(str, "ichapid", tgt->rev_chap_name_len, > > + (char *)ibft_loc + tgt->rev_chap_name_off); > > + if (tgt->rev_chap_secret_len) > > + str += sprintf_string(str, "ichappw", tgt->rev_chap_secret_len, > > + (char *)ibft_loc + tgt->rev_chap_secret_off); > > + > > + /* Cut off the comma. */ > > + str--; > > + > > + return str-buf; > > +} > > Same here, are we writing a novella or something to userspace? :)
Yep. Just like real OFW.
> > > +ssize_t ibft_attr_show_disk(struct ibft_kobject *dev, > > + struct ibft_attribute *ibft_attr, > > + char *buf) > > +{ > > + char *str = buf; > > + > > + str += sprintf(str, "//ethernet@0,%d:iscsi,", dev->data->index); > > + str += ibft_attr_show_initiator(dev, ibft_attr, str); > > + str += sprintf(str, ","); > > + str += ibft_attr_show_target(dev, ibft_attr, str); > > + str += sprintf(str, ","); > > + str += ibft_attr_show_nic(dev, ibft_attr, str); > > + > > + return str-buf; > > +} > > And here, do I need to go on? > > > +ssize_t ibft_attr_show_mac(struct ibft_kobject *entry, > > + struct ibft_attribute *attr, > > + char *buf) > > +{ > > + struct ibft_nic *nic = attr->nic; > > + int len = 6; > > + > > + if (!nic) > > + return 0; > > + > > + memcpy(buf, attr->nic->mac, len); > > + > > + return len; > > +} > > Is mac a user readable string?
Nope. The actual value in OFW is u8[6] in BE. Again, this all input for the fwparam_ppc parser.
++doug
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |