On Mon, Jul 04, 2016 at 10:29:22AM +0200, Hannes Reinecke wrote:
> When running in VN2VN mode there is no central instance which
> would send out any FIP VLAN discovery notifications. So this
> patch adds a new sysfs attribute 'fip_vlan_responder' which
> will activate a FIP VLAN discovery responder.
>
> Signed-off-by: Hannes Reinecke <[email protected]>
> ---
[...]
> +/**
> + * fcoe_ctlr_vlan_send() - Send a FIP VLAN Notification
> + * @fip: The FCoE controller
> + * @sub: sub-opcode for vlan notification or vn2vn vlan notification
> + * @dest: The destination Ethernet MAC address
> + * @min_len: minimum size of the Ethernet payload to be sent
> + */
> +static void fcoe_ctlr_vlan_send(struct fcoe_ctlr *fip,
> + enum fip_vlan_subcode sub,
> + const u8 *dest)
> +{
> + struct sk_buff *skb;
> + struct fip_frame {
> + struct ethhdr eth;
> + struct fip_header fip;
> + struct fip_mac_desc mac;
> + struct fip_vlan_desc vlan;
> + } __packed * frame;
Hmmm this is the 2nd time fip_frame is defined in fcoe_ctlr.c. I'd prefere
having the type definition somewhere else in this file and then use it in
fcoe_ctlr_vlan_send() and fcoe_ctlr_vn_send().
> + size_t len;
> + size_t dlen;
> +
> + len = sizeof(*frame);
> + dlen = sizeof(frame->mac) + sizeof(frame->vlan);
> + len = max(len, sizeof(struct ethhdr));
> +
> + skb = dev_alloc_skb(len);
> + if (!skb)
> + return;
dev_alloc_skb() uses GFP_ATOMIC so it's actually not unlikely to fail
so please return -ENOMEM here, just so the caller knows what happened.
> +
> + LIBFCOE_FIP_DBG(fip, "fip %s vlan notification, vlan %d\n",
> + fip->mode == FIP_MODE_VN2VN ? "vn2vn" : "fcf",
> + fip->lp->vlan);
> +
> + frame = (struct fip_frame *)skb->data;
> + memset(frame, 0, len);
> + memcpy(frame->eth.h_dest, dest, ETH_ALEN);
> +
> + memcpy(frame->eth.h_source, fip->ctl_src_addr, ETH_ALEN);
> + frame->eth.h_proto = htons(ETH_P_FIP);
> +
> + frame->fip.fip_ver = FIP_VER_ENCAPS(FIP_VER);
> + frame->fip.fip_op = htons(FIP_OP_VLAN);
> + frame->fip.fip_subcode = sub;
> + frame->fip.fip_dl_len = htons(dlen / FIP_BPW);
> +
> + frame->mac.fd_desc.fip_dtype = FIP_DT_MAC;
> + frame->mac.fd_desc.fip_dlen = sizeof(frame->mac) / FIP_BPW;
> + memcpy(frame->mac.fd_mac, fip->ctl_src_addr, ETH_ALEN);
> +
> + frame->vlan.fd_desc.fip_dtype = FIP_DT_VLAN;
> + frame->vlan.fd_desc.fip_dlen = sizeof(frame->vlan) / FIP_BPW;
> + put_unaligned_be16(fip->lp->vlan, &frame->vlan.fd_vlan);
> +
> + skb_put(skb, len);
> + skb->protocol = htons(ETH_P_FIP);
> + skb->priority = fip->priority;
> + skb_reset_mac_header(skb);
> + skb_reset_network_header(skb);
> +
> + fip->send(fip, skb);
> +}
--
Johannes Thumshirn Storage
[email protected] +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html