Remove support for the pre-T11 FCoE protocol.
Signed-off-by: Joe Eykholt <[EMAIL PROTECTED]>
---
usr/common/include/fc_fcoe.h | 52 --
usr/common/libfc/src/encaps/Makefile.libfc | 1
usr/common/libfc/src/encaps/fcoe.c | 21 -
usr/common/libfc/src/encaps/fcoe_old.c | 650 ----------------------------
4 files changed, 1 insertions(+), 723 deletions(-)
delete mode 100644 usr/common/libfc/src/encaps/fcoe_old.c
diff --git a/usr/common/include/fc_fcoe.h b/usr/common/include/fc_fcoe.h
index e807ed2..c1c55b0 100644
--- a/usr/common/include/fc_fcoe.h
+++ b/usr/common/include/fc_fcoe.h
@@ -48,54 +48,6 @@
#define FC_FCOE_ENCAPS_ID(n) (((u_int64_t) FC_FCOE_OUI << 24) | (n))
#define FC_FCOE_DECAPS_ID(n) ((n) >> 24)
-#ifndef FCOE_T11_AUG07 /* old version */
-
-/*
- * Start of frame values.
- * For FCOE the SOF value is encoded in 4 bits by simply trimming the
- * standard RFC 3643 encapsulation values. See fc/encaps.h.
- *
- * The following macros work for class 3 and class F traffic.
- * It is still required to use net access functions to do the byte swapping.
- *
- * SOF code Normal FCOE
- * SOFf 0x28 8
- * SOFi3 0x2e e
- * SOFn3 0x36 6
- */
-#define FC_FCOE_ENCAPS_LEN_SOF(len, sof) \
- ((FC_FCOE_VER << 14) | (((len) & 0x3ff) << 4) | ((sof) & 0xf))
-#define FC_FCOE_DECAPS_VER(n) ((n) >> 14)
-#define FC_FCOE_DECAPS_LEN(n) (((n) >> 4) & 0x3ff)
-#define FC_FCOE_DECAPS_SOF(n) \
- (((n) & 0x8) ? (((n) & 0xf) + 0x20) : (((n) & 0xf) + 0x30))
-
-/*
- * FCoE frame header
- *
- * NB: This is the old version, defined before August 2007.
- *
- * This follows the VLAN header, which includes the ethertype.
- * The version is the MS 2 bits, followed by the 10-bit length (in 32b words),
- * followed by the 4-bit encoded SOF as the LSBs.
- */
-struct fcoe_hdr {
- net16_t fcoe_plen; /* fc frame len and SOF */
-};
-
-/*
- * FCoE CRC & EOF
- * NB: This is the old version, defined before August 2007.
- */
-struct fcoe_crc_eof {
- u_int32_t fcoe_crc32; /* CRC for FC packet */
- net8_t fcoe_eof; /* EOF from RFC 3643 */
-} __attribute__((packed));
-
-#define FCOE_CRC_LEN 4 /* byte length of the FC CRC */
-
-#else /* FCOE_T11_AUG07 */
-
/*
* FCoE frame header - 14 bytes
*
@@ -115,13 +67,11 @@ struct fcoe_hdr {
* FCoE CRC & EOF - 8 bytes.
*/
struct fcoe_crc_eof {
- u_int32_t fcoe_crc32; /* CRC for FC packet */
+ u_int32_t fcoe_crc32; /* CRC for FC packet (little-endian) */
net8_t fcoe_eof; /* EOF from RFC 3643 */
net8_t fcoe_resvd[3]; /* reserved - send zero and ignore */
} __attribute__((packed));
-#endif /* FCOE_T11_AUG07 */
-
/*
* Store OUI + DID into MAC address field.
*/
diff --git a/usr/common/libfc/src/encaps/Makefile.libfc
b/usr/common/libfc/src/encaps/Makefile.libfc
index 4f8ac85..fc0d4f0 100644
--- a/usr/common/libfc/src/encaps/Makefile.libfc
+++ b/usr/common/libfc/src/encaps/Makefile.libfc
@@ -3,5 +3,4 @@
SOURCES += \
fcip.c \
fcoe.c \
- fcoe_old.c \
$(NULL)
diff --git a/usr/common/libfc/src/encaps/fcoe.c
b/usr/common/libfc/src/encaps/fcoe.c
index 54bc628..9a01184 100644
--- a/usr/common/libfc/src/encaps/fcoe.c
+++ b/usr/common/libfc/src/encaps/fcoe.c
@@ -23,8 +23,6 @@
*
* This module handles FCoE sending and receiving over an fc_port interface.
*/
-#define FCOE_T11_AUG07 /* get new T11 8/07 version of FCoE defs */
-
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
@@ -60,19 +58,11 @@
#define FCOE_ET_VAR "FCOE_ETHERTYPE" /* env. var. for ethertype */
#define FCOE_OUI_VAR "FCOE_OUI" /* env. var. for OUI */
-#define FCOE_OLD_VAR "FCOE_OLD_%s" /* env. var. for old version */
-#define FCOE_OLD_ALL_VAR "FCOE_OLD_ALL" /* env. var. for old version */
#define FC_FCOE_BUFLEN 2200 /* buffer size for reads */
#define FC_FCOE_SOCKBUF_LEN (512 * 1024) /* requested receive socket buf size
*/
/*
- * Temporarily provide hook to old pre-T11 protocol.
- */
-struct fc_port * fc_fcoe_create_old(const char *, u_int,
- const u_char *, const u_char *, u_int);
-
-/*
* Private per-FCoE connection state.
*/
struct fc_fcoe {
@@ -155,17 +145,6 @@ fc_fcoe_create(const char *ifname, u_int vlan,
u_int16_t ethertype;
u_int16_t fc_et;
u_long fc_oui;
- char buf[40];
-
- /*
- * Test for presense of env. variables FCOE_OLD_<ifname> or FCOE_OLD_ALL.
- * If any of these are there, the older protocol version is used.
- */
- snprintf(buf, sizeof (buf), FCOE_OLD_VAR, ifname);
- if (getenv(buf) != NULL || getenv(FCOE_OLD_ALL_VAR) != NULL ||
- (options & FC_OPT_FCOE_OLD) != 0) {
- return (fc_fcoe_create_old(ifname, vlan, src_mac, dest_mac, options));
- }
ASSERT(vlan == 0); /* obsolete and untested mode */
diff --git a/usr/common/libfc/src/encaps/fcoe_old.c
b/usr/common/libfc/src/encaps/fcoe_old.c
deleted file mode 100644
index 18da025..0000000
--- a/usr/common/libfc/src/encaps/fcoe_old.c
+++ /dev/null
@@ -1,650 +0,0 @@
-/*
- * Copyright(c) 2007 Intel Corporation. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Maintained at www.Open-FCoE.org
- */
-
-/*
- * FCoE encapsulation / decapsulation and state management.
- * See RFC 3643 - Fibre Channel Frame Encapsulation.
- *
- * This module handles FCoE sending and receiving over an fc_port interface.
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/ioctl.h>
-#include <net/if.h>
-#include <netpacket/packet.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/fcntl.h>
-
-#include "sa_kernel.h"
-#include "sa_assert.h"
-#include "net_types.h"
-#include "sa_event.h"
-#include "sa_packet.h"
-
-#include <linux/types.h>
-#include <linux/if_ether.h>
-#include <linux/if_vlan.h>
-
-#include "fc_types.h"
-#include "sa_select.h"
-#include "sa_buf.h"
-#include "sa_log.h"
-#include "sa_link_event.h"
-
-#include "ether_crc32.h"
-#include "fc_encaps.h"
-#include "fc_fcoe.h"
-#include "fc_port.h"
-#include "fc_frame.h"
-#include "fc_print.h"
-#include "fc_els.h"
-
-#define FCOE_ET_VAR "FCOE_ETHERTYPE" /* env. var. for ethertype */
-#define FCOE_OUI_VAR "FCOE_OUI" /* env. var. for OUI */
-
-#define FC_FCOE_BUFLEN 2200 /* buffer size for reads */
-#define FC_FCOE_SOCKBUF_LEN (512 * 1024) /* requested receive socket buf size
*/
-
-/*
- * Private per-FCoE connection state.
- */
-struct fc_fcoe {
- int fc_fd; /* raw ethernet file descriptor */
- int fc_ifindex; /* kernel interface index */
- struct fc_port *fc_port; /* interface to upper layers */
- u_int fc_options;
- u_int fc_prepend_failed;
- u_int fc_vlan; /* VLAN number */
- u_char fc_dest_mac_valid; /* non-zero if dest MAC set */
- u_char fc_dest_mac_learn; /* non-zero if dest should be learned
*/
- u_char fc_dest_mac[ETH_ALEN]; /* destination MAC, if non-zero */
- u_char fc_src_mac[ETH_ALEN]; /* MAC to use for source */
- u_char fc_hw_mac[ETH_ALEN]; /* MAC from interface */
- u_int fc_oui; /* OUI for standard addressing */
- u_int16_t fc_ethertype; /* ethertype for FCoE */
- u_char fc_flogi_mac[ETH_ALEN]; /* MAC for FLOGI dest */
- char fc_ifname[IFNAMSIZ];
-};
-
-/*
- * Statistics and other module variables.
- */
-static struct fc_fcoe_state {
- u_int fc_frames_good;
- u_int fc_frames_bad;
- u_int fc_prepend_failed;
-} fc_fcoe_state;
-
-static void fc_fcoe_event_old(int, void *);
-static void fc_fcoe_recv_old(void *fcoe_arg);
-static int fc_fcoe_send_old(void *, struct fc_frame *);
-static int fc_fcoe_port_control_old(void *, enum fc_port_ctl, void *, size_t);
-
-static unsigned long
-fc_fcoe_getenv_val(const char *var, int base,
- unsigned long def_val, unsigned long min_val, unsigned long max_val)
-{
- unsigned long opt_val;
- char *opt;
- char *endptr;
-
- opt = getenv(var);
- if (opt != NULL) {
- opt_val = strtoul(opt, &endptr, base);
- if (*endptr != '\0' || opt_val < min_val || opt_val > max_val) {
- sa_log("%s env var '%s' invalid - ignored", var, opt);
- } else if (opt_val != def_val) {
- sa_log("%s env var overrides default %lx with %lx",
- var, def_val, opt_val);
- def_val = opt_val;
- }
- }
- return (def_val);
-}
-
-static void
-fc_fcoe_link_event(int up, void *port_arg)
-{
- SA_LOG("link %s", up ? "up" : "down");
- fc_port_send_event(port_arg, up ? FC_EV_READY : FC_EV_DOWN);
-}
-
-/*
- * Open FCoE socket.
- * Returns a port which can then be connected to an upper layer.
- */
-struct fc_port *
-fc_fcoe_create_old(const char *ifname, u_int vlan,
- const u_char *src_mac, const u_char *dest_mac, u_int options)
-{
-
- struct ifreq ifr;
- struct fc_fcoe *fcoe;
- struct fc_port *port = NULL;
- int fd;
- int rc;
- int mtu;
- int rx_buf;
- socklen_t arg_size;
- u_int16_t ethertype;
- u_int16_t fc_et;
- u_long fc_oui;
-
- ASSERT(vlan == 0); /* obsolete and untested mode */
-
- /*
- * Allow ethertype and OUI to be overridden from the environment.
- */
- fc_et = fc_fcoe_getenv_val(FCOE_ET_VAR, 16, ETH_P_FCOE, 1, 0xffff);
- fc_oui = fc_fcoe_getenv_val(FCOE_OUI_VAR, 16, FC_FCOE_OUI, 1, 0xfffffe);
- ethertype = vlan ? ETH_P_8021Q : fc_et;
-
-
- fd = sa_packet_open(ifname, SOCK_RAW, ethertype,
- (options & FC_OPT_SET_MAC) == 0);
- if (fd == -1) {
- SA_LOG_ERR_EXIT(errno, "raw socket open failed");
- }
-
- /*
- * Get receive buffer size and increase if needed.
- */
- arg_size = sizeof (rx_buf);
- rc = getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rx_buf, &arg_size);
- if (rc == -1) {
- SA_LOG_ERR_EXIT(errno, "getsockopt SO_RCVBUF error");
- }
- if (rx_buf < FC_FCOE_SOCKBUF_LEN) {
- rx_buf = FC_FCOE_SOCKBUF_LEN;
- arg_size = sizeof (rx_buf);
- rc = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rx_buf, arg_size);
- if (rc == -1) {
- SA_LOG_ERR_EXIT(errno, "setsockopt SO_RCVBUF error");
- }
- }
-
- fcoe = sa_malloc(sizeof (*fcoe));
- if (fcoe == NULL) {
- SA_LOG_EXIT("FCIP calloc failed");
- }
- memset(fcoe, 0, sizeof (*fcoe));
- strncpy(fcoe->fc_ifname, ifname, sizeof (fcoe->fc_ifname));
- fcoe->fc_fd = fd;
- fcoe->fc_vlan = vlan;
- fcoe->fc_options = options;
- fcoe->fc_oui = fc_oui;
- fcoe->fc_ethertype = fc_et;
- net48_put((net48_t *) &fcoe->fc_flogi_mac, FC_FCOE_FLOGI_MAC);
- if (fc_oui != FC_FCOE_OUI) {
- net24_put((net24_t *) &fcoe->fc_flogi_mac, fc_oui);
- }
-
- /*
- * Set the source MAC address as specified or get it from the ethernet
port.
- */
- memset(&ifr, 0, sizeof (ifr));
- strncpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
- rc = ioctl(fd, SIOCGIFHWADDR, &ifr);
- if (rc == -1) {
- SA_LOG_ERR_EXIT(errno, "SIOGCIFHWADDR failed");
- }
- memcpy(fcoe->fc_hw_mac, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
- if (src_mac == NULL) {
- src_mac = (u_char *) ifr.ifr_hwaddr.sa_data;
- }
- memcpy(fcoe->fc_src_mac, src_mac, ETH_ALEN);
-
- /*
- * Get the ifindex.
- */
- memset(&ifr, 0, sizeof (ifr));
- strncpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
- rc = ioctl(fd, SIOCGIFINDEX, &ifr);
- if (rc == -1) {
- SA_LOG_ERR_EXIT(errno, "SIOGCIFINDEX failed");
- }
- fcoe->fc_ifindex = ifr.ifr_ifindex;
-
- /*
- * Get the MTU.
- */
- memset(&ifr, 0, sizeof (ifr));
- strncpy(ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
- rc = ioctl(fd, SIOCGIFMTU, &ifr);
- if (rc == -1) {
- SA_LOG_ERR_EXIT(errno, "SIOGCIFMTU failed");
- }
- mtu = ifr.ifr_mtu; /* MTU doesn't include ethernet header */
- ASSERT(mtu >= 1500 - 8); /* 1100 or so would be actually OK */
- mtu -= (sizeof (struct fcoe_hdr) + sizeof (struct fcoe_crc_eof));
- ASSERT(mtu > sizeof (struct fc_frame_header) + 512);
-
- /*
- * Set the destination MAC address, if specified.
- * This cannot be specified for standard addressing.
- * For non-standard addressing, if not specified,
- * it will come from the first received packet's source address.
- */
- if (dest_mac != NULL) {
- options |= FC_OPT_SET_MAC;
- fcoe->fc_options |= FC_OPT_SET_MAC;
- memcpy(fcoe->fc_dest_mac, dest_mac, sizeof (fcoe->fc_dest_mac));
- fcoe->fc_dest_mac_valid = 1;
- } else if (options & FC_OPT_SET_MAC) {
- fcoe->fc_dest_mac_learn = 1;
- }
-
- port = fc_port_alloc();
- if (port != NULL) {
- fcoe->fc_port = port;
- fc_port_set_max_frame_size(port, mtu);
- fc_port_set_egress(port, fc_fcoe_send_old, fcoe);
- fc_port_set_egress_control(port, fc_fcoe_port_control_old);
- fc_port_enq_handler(port, fc_fcoe_event_old, fcoe);
- sa_select_add_fd(fd, fc_fcoe_recv_old, NULL, NULL, fcoe);
-
- /*
- * Set no-delay.
- */
- rc = fcntl(fd, F_GETFD);
- if (rc == -1 ||
- (rc == fcntl(fd, F_SETFD, rc | O_NONBLOCK)) == -1) {
- SA_LOG_ERR_EXIT(errno, "fcntl error");
- }
- sa_link_event_enq(fcoe->fc_ifindex, fc_fcoe_link_event, port);
- } else {
- free(fcoe);
- }
- return (port);
-}
-
-/*
- * Close down if client closed its side of port.
- */
-static void
-fc_fcoe_event_old(int event, void *fcoe_arg)
-{
- struct fc_fcoe *fcoe = fcoe_arg;
- struct fc_port *port;
-
- if (event == FC_EV_CLOSED) {
- port = fcoe->fc_port;
- sa_link_event_deq(fcoe->fc_ifindex, fc_fcoe_link_event, port);
- fc_port_deq_handler(port, fc_fcoe_event_old, fcoe);
- fc_port_close_egress(port);
- close(fcoe->fc_fd);
- free(fcoe);
- }
-}
-
-/*
- * Accumulate and validate incoming frames.
- * Pass to upper-level handler for connection.
- */
-static void
-fc_fcoe_recv_old(void *fcoe_arg)
-{
- struct fc_fcoe *fcoe = (struct fc_fcoe *) fcoe_arg;
- struct sockaddr_ll from;
- socklen_t fromlen;
- struct ethhdr *ep;
- struct fcoe_hdr *eh;
- struct fcoe_crc_eof *tp;
- struct fc_frame *fp;
- size_t len;
- ssize_t rc;
- net16_t *etp;
- u_int16_t tag;
- u_int16_t ethertype;
- u_int16_t len_sof;
- u_int flen;
- char *error = NULL;
- u_int32_t crc;
- u_int32_t expected;
-
- fp = fc_frame_alloc_int(FC_FCOE_BUFLEN);
- ASSERT(fp != NULL);
- if (fp != NULL) {
- memset(&from, 0, sizeof (from));
- fromlen = sizeof (from);
- rc = recvfrom(fcoe->fc_fd, fp->fr_sg[0].frs_buf, FC_FCOE_BUFLEN,
- 0, (struct sockaddr *) &from, &fromlen);
- if (rc < 0) {
- if (errno == ENETDOWN) {
- error = "net down";
- goto err;
- }
- SA_LOG_ERR_EXIT(errno, "recv failed");
- }
- len = rc;
-
- if (fcoe->fc_options & FC_OPT_DEBUG_RX) {
- SA_LOG("fromlen %d ifindex %d proto %x atype %x alen %x "
- "pkttype %x len %d",
- fromlen, from.sll_ifindex,
- ntohs(from.sll_protocol), from.sll_hatype,
- from.sll_halen, from.sll_pkttype, len);
- }
- if (len < sizeof (struct ethhdr) +
- sizeof (struct fcoe_hdr) + sizeof (struct fc_frame_header) +
- sizeof (struct fcoe_crc_eof)) {
- SA_LOG("short frame. Received len %d\n", len);
- goto err;
- }
- ep = fp->fr_sg[0].frs_buf;
- fp->fr_eth_hdr = ep;
-
- /*
- * Check ethertype and handle optional (multiple) VLAN encapsulations.
- */
- etp = (net16_t *) &ep->h_proto; /* set pointer to ethertype */
- len -= sizeof (*ep);
- eh = NULL;
- do {
- if (len < sizeof (*etp) + sizeof (*eh)) {
- error = "length error";
- goto err;
- }
- ethertype = net16_get(etp);
- if (ethertype == fcoe->fc_ethertype) {
- eh = (struct fcoe_hdr *) (ep + 1);
- } else if (ethertype == ETH_P_8021Q) {
- tag = net16_get(etp + 1);
- if ((tag & 0xfff) != fcoe->fc_vlan) {
- error = "wrong VLAN";
- goto err;
- }
- etp = &((struct fcoe_vlan_hdr *) (etp + 1))->vlan_ethertype;
- len -= sizeof (struct fcoe_vlan_hdr);
- } else {
- SA_LOG("ethertype %x\n", ethertype);
- error = "unrecognized ethertype";
- goto err;
- }
- } while (eh == NULL);
-
- if (fcoe->fc_dest_mac_learn) {
- memcpy(fcoe->fc_dest_mac, ep->h_source, ETH_ALEN);
- fcoe->fc_dest_mac_valid = 1;
- }
-
- len_sof = net16_get(&eh->fcoe_plen);
- flen = FC_FCOE_DECAPS_LEN(len_sof) * sizeof (u_int32_t);
- flen -= sizeof (crc);
- fp->fr_sof = FC_FCOE_DECAPS_SOF(len_sof);
- len -= (sizeof (*eh) + sizeof (crc));
- ASSERT(len >= flen);
- len = flen;
-
- fp->fr_hdr = (struct fc_frame_header *) (eh + 1);
- fp->fr_sg[0].frs_buf = (void *) (eh + 1);
- fp->fr_sg[0].frs_len = len;
- fp->fr_len = len;
-
- tp = (struct fcoe_crc_eof *) ((char *) (eh + 1) + len);
- fp->fr_eof = tp->fcoe_eof;
-
- crc = tp->fcoe_crc32;
- if (fcoe->fc_options & FC_OPT_NO_RX_CRC) {
- expected = crc;
- } else {
- expected = ~ether_crc32_le(fp->fr_sg[0].frs_buf,
- fp->fr_sg[0].frs_len);
- }
- if (crc != expected) {
- fc_fcoe_state.fc_frames_bad++;
- SA_LOG("FCoE *** BAD CRC *** "
- "saw %x expected %x frames %d errs %d\n",
- crc, expected, fc_fcoe_state.fc_frames_good,
- fc_fcoe_state.fc_frames_bad);
- SA_LOG("FCoE flen %d buf len %zd\n", flen, len);
- fc_print_frame_hdr("fc_fcoe_recv_old CRC err", fp);
- memset(eh, 0xaa, flen); /* scribble */
- } else {
- fc_fcoe_state.fc_frames_good++;
- if (fcoe->fc_options & FC_OPT_DEBUG_RX) {
- fc_print_frame_hdr("fc_fcoe_recv_old", fp);
- }
- fp->fr_in_port = fcoe->fc_port;
- fc_port_ingress(fcoe->fc_port, fp);
- fp = NULL;
- }
- }
-err:
- if (error != NULL) {
- SA_LOG("FCoE recv %s error", error);
- }
- if (fp != NULL) {
- fc_frame_free(fp);
- }
-}
-
-/*
- * FCoE send.
- * Send a fibre-channel frame out an ethernet port after encapsulating it.
- *
- * Padding: The buffer must be a multiple of 4 bytes long when we send it,
- * and this routine supplies the necessary padding.
- */
-static int
-fc_fcoe_send_old(void *fcoe_arg, struct fc_frame *fp)
-{
- struct fc_fcoe *fcoe = fcoe_arg;
- struct fc_frame_header *fh;
- union {
- struct ethhdr eth;
- struct {
- struct ethhdr eth;
- struct fcoe_hdr fcoe;
- } no_vlan;
- struct {
- struct ethhdr eth;
- struct fcoe_vlan_hdr vlan;
- struct fcoe_hdr fcoe;
- } vlan;
- struct {
- net24_t da_oui;
- net24_t da_id;
- net24_t sa_oui;
- net24_t sa_id;
- } fcoe;
- } head;
- struct fcoe_crc_eof tail;
- struct fc_frame_sg *sg;
- static char pad_buffer[4]; /* a supply of zeros for padding */
- size_t len;
- int flen; /* overall FCIP frame len in words */
- int plen; /* padding length */
- u_int32_t crc;
- struct iovec msg_iov[FC_FRAME_SG_LEN + 4];
- struct iovec *iov;
- struct msghdr msg;
- u_char op;
- int rc;
-
- len = fp->fr_len;
- ASSERT(len >= sizeof (struct fc_frame_header));
-
- /*
- * Check for the delimiters we currently use.
- * Others are legal but not expected.
- */
- ASSERT(fp->fr_sof == FC_SOF_I3 || fp->fr_sof == FC_SOF_N3 ||
- fp->fr_sof == FC_SOF_F);
- ASSERT(fp->fr_eof == FC_EOF_T || fp->fr_eof == FC_EOF_N);
-
- flen = (len + 3) / 4; /* round up to next word */
- plen = flen * 4; /* length including padding */
- plen -= len;
- ASSERT(plen >= 0); /* padding length must be positive */
- flen += sizeof (tail.fcoe_crc32) / 4;
-
- if (fcoe->fc_options & FC_OPT_DEBUG_TX) {
- fc_print_frame_hdr("fc_fcoe_send_old", fp);
- }
-
- /*
- * Build gather list. The elements are the encapsulation header, followed
- * by the gather list from the packet, followed by optional padding,
- * then the tail (CRC and EOF).
- *
- * Build the header depending on whether we want the VLAN encapsulation or
- * not. Building with the VLAN is rare, but useful for testing.
- */
- iov = msg_iov;
- memset(&head, 0, sizeof (head));
-
- /*
- * Fill in MAC addresses.
- */
- fh = fc_frame_header_get(fp);
- ASSERT(fh != NULL);
- if (fcoe->fc_options & FC_OPT_SET_MAC) { /* non-standard mode */
- if (fcoe->fc_dest_mac_valid == 0) {
- SA_LOG("dest MAC not set. dropping frame");
- rc = EINVAL;
- goto out;
- }
- memcpy(head.eth.h_dest, fcoe->fc_dest_mac, ETH_ALEN);
- memcpy(head.eth.h_source, fcoe->fc_src_mac, ETH_ALEN);
- } else if (fp->fr_eth_tx != NULL) { /* for FLOGI response */
- memcpy(&head.eth, fp->fr_eth_tx, 2 * ETH_ALEN);
- } else if (fh->fh_r_ctl == FC_RCTL_ELS_REQ &&
- net24_get(&fh->fh_d_id) == FC_FID_FLOGI &&
- fh->fh_type == FC_TYPE_ELS &&
- ((op = fc_frame_payload_op(fp)) == ELS_FLOGI || op == ELS_FDISC)) {
-
- /*
- * FLOGI or FDISC request.
- */
- memcpy(head.eth.h_dest, fcoe->fc_flogi_mac, ETH_ALEN);
- if (net24_get(&fh->fh_s_id) == 0) {
- memcpy(head.eth.h_source, fcoe->fc_src_mac, ETH_ALEN);
- } else {
- net24_put(&head.fcoe.sa_oui, fcoe->fc_oui);
- head.fcoe.sa_id = fh->fh_s_id;
- }
- } else { /* normal FCoE address */
- net24_put(&head.fcoe.da_oui, fcoe->fc_oui);
- head.fcoe.da_id = fh->fh_d_id;
- head.fcoe.sa_oui = head.fcoe.da_oui;
- head.fcoe.sa_id = fh->fh_s_id;
- }
-
- /*
- * Fill in VLAN header and ethertype.
- */
- if (fcoe->fc_vlan != 0) {
- head.eth.h_proto = htons(ETH_P_8021Q);
- net16_put(&head.vlan.vlan.vlan_tag, fcoe->fc_vlan);
- net16_put(&head.vlan.vlan.vlan_ethertype, fcoe->fc_ethertype);
- net16_put(&head.vlan.fcoe.fcoe_plen,
- FC_FCOE_ENCAPS_LEN_SOF(flen, fp->fr_sof));
- iov->iov_base = &head.vlan;
- iov->iov_len = sizeof (head.vlan);
- iov++;
- } else {
- head.eth.h_proto = htons(fcoe->fc_ethertype);
- net16_put(&head.no_vlan.fcoe.fcoe_plen,
- FC_FCOE_ENCAPS_LEN_SOF(flen, fp->fr_sof));
- iov->iov_base = &head.no_vlan;
- iov->iov_len = sizeof (head.no_vlan);
- iov++;
- }
- crc = ETHER_CRC32_SEED;
- ASSERT(fp->fr_sg_len > 0);
- ASSERT(fp->fr_sg_len <= FC_FRAME_SG_LEN);
- for (sg = fp->fr_sg; sg < &fp->fr_sg[fp->fr_sg_len]; sg++) {
- ASSERT(sg->frs_buf != NULL);
- ASSERT(sg->frs_len != 0);
- iov->iov_base = sg->frs_buf;
- iov->iov_len = sg->frs_len;
- if ((fcoe->fc_options & FC_OPT_NO_TX_CRC) == 0) {
- crc = ether_crc32_le_partial(iov->iov_base, iov->iov_len, crc);
- }
- iov++;
- }
- if (plen > 0) {
- iov->iov_base = pad_buffer;
- iov->iov_len = plen;
- if ((fcoe->fc_options & FC_OPT_NO_TX_CRC) == 0) {
- crc = ether_crc32_le_partial(iov->iov_base, iov->iov_len, crc);
- }
- iov++;
- }
- tail.fcoe_crc32 = ~crc; /* finally invert CRC */
- tail.fcoe_eof = fp->fr_eof;
- iov->iov_base = &tail;
- iov->iov_len = sizeof (tail);
- iov++;
- ASSERT(iov <= &msg_iov[sizeof (msg_iov) / sizeof (msg_iov[0])]);
- ASSERT(iov - msg_iov == fp->fr_sg_len + 2 + (plen > 0));
- msg.msg_iovlen = iov - msg_iov;
- msg.msg_name = NULL;
- msg.msg_namelen = 0;
- msg.msg_iov = msg_iov;
- msg.msg_control = NULL;
- msg.msg_controllen = 0;
- msg.msg_flags = MSG_DONTWAIT;
-
- /*
- * Send frame.
- */
- rc = sendmsg(fcoe->fc_fd, &msg, 0);
- if (rc == -1) {
- rc = errno;
- SA_LOG_ERR_EXIT(errno, "sendmsg error");
- } else {
- rc = 0;
- }
-out:
- fc_frame_free(fp);
- return (rc);
-}
-
-/*
- * Port control functions.
- */
-static int
-fc_fcoe_port_control_old(void *fcoe_arg,
- enum fc_port_ctl op, void *buf, size_t len)
-{
- struct fc_fcoe *fcoe = fcoe_arg;
- int rc = -ENOTTY;
- fc_wwn_t wwn;
- u_int64_t mac;
-
- switch (op) {
- case FC_PCTL_GET_WWNN:
- case FC_PCTL_GET_WWPN:
- rc = -EINVAL;
- if (len >= sizeof (wwn)) {
- rc = sizeof (wwn);
- mac = net48_get((net48_t *) fcoe->fc_hw_mac);
- wwn = fc_wwn_from_mac(mac, op == FC_PCTL_GET_WWNN ? 1 : 2, 0);
- memcpy(buf, &wwn, sizeof (wwn));
- }
- break;
- default:
- break;
- }
- return (rc);
-}
_______________________________________________
devel mailing list
[email protected]
http://www.open-fcoe.org/mailman/listinfo/devel