openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

fcoe.c (74582B)


      1 /*
      2  * 
      3  *
      4  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      5  * 
      6  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      7  */
      8 #define FIP_VERSION_1  0 
      9 
     10 #include <sal/appl/sal.h>
     11 #include <sal/appl/config.h>
     12 #include <sal/appl/io.h>
     13 #include <sal/core/alloc.h>
     14 #include <sal/core/thread.h>
     15 #include <shared/bsl.h>
     16 #include <bcm/error.h>
     17 #include <bcm/tx.h>
     18 #include <bcm/rx.h>
     19 #include <bcm/link.h>
     20 #include <bcm/vlan.h>
     21 #include <bcm/stat.h>
     22 #include <bcm/field.h>
     23 #include <bcm/port.h>
     24 #include <bcm/fcmap.h>
     25 #include <soc/enet.h>
     26 #include <soc/debug.h>
     27 #include <soc/cm.h>
     28 #include <appl/diag/shell.h>
     29 #include <appl/diag/system.h>
     30 #include <appl/diag/dport.h>
     31 
     32 #include <sal/core/dpc.h>
     33 #include <sal/core/time.h>
     34 #include <soc/phy/phyctrl.h>
     35 
     36 #ifdef INCLUDE_FCMAP
     37 #ifdef BCM_WARM_BOOT_SUPPORT
     38 extern void bfcmap_warmboot_recover(void);
     39 #endif
     40 extern int phy_is_8806x(phy_ctrl_t *pc);
     41 typedef struct fip_flogi_s {
     42     char used;
     43     sal_mac_addr_t sa;
     44     int unit;
     45     int port;
     46     uint16 oxid;
     47     uint16 rxid;
     48 }fip_flogi_t;
     49 
     50 #define FCOE_MAX_FIP_FLOGI 256
     51 fip_flogi_t fip_flogi_pending[FCOE_MAX_FIP_FLOGI];
     52 
     53 
     54 bcm_mac_t  fcf_sa_mac = {0x00,0x10,0x18,0x01,0x02,0x03};
     55 static volatile sal_thread_t fcoe_thread_id = SAL_THREAD_ERROR;
     56 
     57 static int fcoe_fc_port; /* FC port */
     58 STATIC void _print_fcmap_cfg(bcm_fcmap_port_config_t *cfg);
     59 STATIC void fcoe_fip_thread(void *cookie);
     60 int is_mt2 = 0; /* Flag to indicate MT2 present */
     61 
     62 unsigned char lldp[] = {
     63 0x01, 0x80, 0xC2, 0x00, 0x00, 0x0E, 0x00, 0x10, 
     64 0x18, 0x01, 0x02, 0x03, 0x88, 0xCC, 0x02, 0x07, 
     65 0x04, 0x00, 0x10, 0x18, 0x01, 0x02, 0x03, 0x04, 
     66 0x07, 0x05, 0x45, 0x74, 0x68, 0x31, 0x2F, 0x39, 
     67 0x06, 0x02, 0x00, 0x78, 0x08, 0x09, 0x4E, 0x35, 
     68 0x4B, 0x2D, 0x50, 0x6F, 0x72, 0x74, 0x00, 0x0A, 
     69 0x07, 0x73, 0x77, 0x69, 0x74, 0x63, 0x68, 0x00, 
     70 0x0C, 0x0A, 0x4E, 0x35, 0x4B, 0x2D, 0x53, 0x77, 
     71 0x69, 0x74, 0x63, 0x68, 0x0E, 0x04, 0x00, 0x04, 
     72 0x00, 0x04, 0x10, 0x0E, 0x07, 0x06, 0x00, 0x0D, 
     73 0xEC, 0xCD, 0xFD, 0x00, 0x02, 0x1A, 0x00, 0x80, 
     74 0x00, 0x00, 0xFE, 0x37, 0x00, 0x1B, 0x21, 0x02, 
     75 0x02, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 
     76 0x00, 0x00, 0x00, 0x01, 0x06, 0x06, 0x00, 0x00, 
     77 0x80, 0x00, 0x08, 0x08, 0x08, 0x0A, 0x00, 0x00, 
     78 0x80, 0x00, 0x89, 0x06, 0x00, 0x1B, 0x21, 0x08, 
     79 0x04, 0x11, 0x00, 0x00, 0x80, 0x00, 0x00, 0x01, 
     80 0x00, 0x00, 0x32, 0x32, 0x00, 0x00, 0x00, 0x00, 
     81 0x00, 0x00, 0x02, 0xFE, 0x05, 0x00, 0x01, 0x42, 
     82 0x01, 0x01, 0xFE, 0x06, 0x00, 0x80, 0xC2, 0x01, 
     83 0x00, 0x01, 0x00, 0x00, 0xBC, 0x2A, 0x44, 0x0A, 
     84 0xFD, 0x07, 0x07, 0x07};
     85 
     86 unsigned char FLOGI_Request[] = 
     87 {0x00, 0x0D, 0xEC, 0xCD, 0xFD, 0x00, 0x00, 0xC0, 0xDD, 0x12, 0xAB, 0x1D, 0x81,
     88 0x00, 0x60, 0x04, 0x89, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     89 0x00, 0x00, 0x00, 0x00, 0x00, 0x2E, 0x22, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00,
     90 0x00, 0x01, 0x29, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x00, 0x19, 0xFF, 0xFF,
     91 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x20, 0x00, 0x0f, 0x80,
     92 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00,
     93 0x00, 0x10, 0x18, 0x44, 0x2f, 0x55, 0x20, 0x00, 0x00, 0x10, 0x18, 0x44, 0x2f,
     94 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     95 0x00, 0x01, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00,
     96 0xFF, 0x00, 0x0C, 0x00, 0x01, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x00, 0x00,
     97 0x08, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
     98 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
     99 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    100 0x00, 0x00, 0x00, 0xf0, 0xc3, 0x3c, 0x2b, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00,
    101 0x00, 0x00};
    102 
    103 unsigned char FIP_VLAN_Response[] = {
    104 0x00, 0xc0, 0xdd, 0x12, 0xab, 0x1d, 0x00, 0x10, 
    105 #if FIP_VERSION_1
    106 0x18, 0x01, 0x02, 0x03, 0x89, 0x14, 0x10, 0x00, 
    107 #else
    108 0x18, 0x01, 0x02, 0x03, 0x89, 0x14, 0x00, 0x00, 
    109 #endif
    110 0x00, 0x04, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, 
    111 0x02, 0x02, 0x00, 0x10, 0x18, 0x01, 0x02, 0x03, 
    112 0x0e, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 
    113 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    114 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    115 0x00, 0x00, 0x00, 0x00, 0x50, 0x82, 0x96, 0x32 };
    116 
    117 #if FIP_VERSION_1
    118 unsigned char FIP_Advertisement[] = {
    119 0x00, 0xC0, 0xDD, 0x12, 0xAB, 0x1D, 0x00, 0x10, 0x18, 0x01, 0x02, 0x03, 0x81, 0x00, 0x60, 0x04,
    120 0x89, 0x14, 0x10, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x0d, 0x80, 0x07, 0x01, 0x01, 0x00, 0x80,
    121 0x02, 0x02, 0x00, 0x10, 0x18, 0x01, 0x02, 0x03, 0x04, 0x03, 0x00, 0x00, 0x20, 0x00, 0x00, 0x10,
    122 0xEC, 0xCD, 0xFD, 0x01, 0x05, 0x04, 0x00, 0x00, 0x00, 0x00, 0xFC, 0x00, 0x20, 0x00, 0x00, 0x10,
    123 0xEC, 0xCD, 0xFD, 0x01, 0x0C, 0x02, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x40, 0x06, 0x01, 0x08, 0x2E,
    124 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    125 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    126 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    127 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    128 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    129 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    130 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    131 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    132 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    133 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    134 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    135 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    136 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    137 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    138 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    139 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    140 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    141 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    142 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    143 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    144 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    145 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    146 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    147 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    148 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    149 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    150 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    151 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    152 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    153 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    154 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    155 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    156 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    157 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    158 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    159 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    160 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    161 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    162 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    163 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    164 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    165 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    166 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    167 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    168 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    169 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    170 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    171 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    172 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    173 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    174 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    175 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    176 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    177 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    178 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    179 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    180 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    181 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    182 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    183 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    184 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    185 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    186 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    187 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    188 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    189 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    190 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    191 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    192 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    193 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    194 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    195 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    196 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    197 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    198 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    199 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    200 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    201 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    202 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    203 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    204 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    205 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    206 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    207 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    208 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    209 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    210 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    211 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    212 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    213 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    214 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    215 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    216 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    217 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    218 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    219 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    220 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    221 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    222 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    223 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    224 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    225 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    226 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    227 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    228 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    229 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    230 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    231 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    232 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    233 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    234 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    235 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    236 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    237 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    238 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    239 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    240 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    241 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    242 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    243 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    244 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    245 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    246 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    247 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    248 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    249 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    250 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    251 0xFD, 0x07, 0x07, 0x07};
    252 #else
    253 unsigned char FIP_Advertisement[] = {
    254 0x00, 0xC0, 0xDD, 0x12, 0xAB, 0x1D, 0x00, 0x10, 0x18, 0x01, 0x02, 0x03, 0x81, 0x00, 0x60, 0x04,
    255 0x89, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x0C, 0x80, 0x07, 0x01, 0x01, 0x00, 0x80,
    256 0x02, 0x02, 0x00, 0x10, 0x18, 0x01, 0x02, 0x03, 0x04, 0x03, 0x00, 0x00, 0x20, 0x00, 0x00, 0x10,
    257 0xEC, 0xCD, 0xFD, 0x01, 0x05, 0x04, 0x00, 0x00, 0x00, 0x0E, 0xFC, 0x00, 0x20, 0x00, 0x00, 0x10,
    258 0xEC, 0xCD, 0xFD, 0x01, 0x0C, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    259 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    260 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    261 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    262 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    263 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    264 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    265 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    266 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    267 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    268 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    269 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    270 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    271 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    272 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    273 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    274 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    275 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    276 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    277 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    278 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    279 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    280 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    281 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    282 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    283 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    284 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    285 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    286 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    287 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    288 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    289 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    290 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    291 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    292 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    293 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    294 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    295 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    296 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    297 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    298 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    299 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    300 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    301 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    302 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    303 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    304 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    305 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    306 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    307 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    308 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    309 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    310 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    311 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    312 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    313 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    314 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    315 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    316 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    317 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    318 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    319 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    320 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    321 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    322 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    323 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    324 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    325 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    326 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    327 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    328 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    329 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    330 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    331 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    332 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    333 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    334 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    335 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    336 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    337 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    338 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    339 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    340 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    341 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    342 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    343 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    344 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    345 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    346 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    347 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    348 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    349 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    350 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    351 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    352 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    353 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    354 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    355 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    356 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    357 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    358 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    359 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    360 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    361 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    362 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    363 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    364 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    365 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    366 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    367 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    368 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    369 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    370 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    371 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    372 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    373 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    374 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    375 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    376 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    377 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    378 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    379 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    380 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    381 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    382 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    383 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    384 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    385 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    386 0xFD, 0x07, 0x07, 0x07};
    387 /* 0x6B, 0x7A, 0x56, 0xD3, 0xFD, 0x07, 0x07, 0x07}; */
    388 #endif
    389 
    390 unsigned char FIP_FLOGI_Response[] = {
    391 0x00, 0x10, 0x18, 0x44, 0x2f, 0x55, 0x00, 0x0d, 
    392 0xec, 0xca, 0x05, 0x40, 0x81, 0x00, 0x60, 0x04, 
    393 #if FIP_VERSION_1
    394 0x89, 0x14, 0x10, 0x00, 0x00, 0x02, 0x00, 0x02, 
    395 #else
    396 0x89, 0x14, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 
    397 #endif
    398 0x00, 0x26, 0x80, 0x00, 0x07, 0x24, 0x00, 0x00, 
    399 0x23, 0xb8, 0x02, 0x3c, 0x00, 0xff, 0xff, 0xfe, 
    400 0x01, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    401 0x05, 0x55, 0xd3, 0xc8, 0x00, 0x00, 0x00, 0x00, 
    402 0x02, 0x00, 0x00, 0x00, 0x20, 0x06, 0x00, 0x00, 
    403 0x33, 0x00, 0x08, 0x40, 0x00, 0x00, 0x27, 0x10, 
    404 0x00, 0x00, 0x07, 0xd0, 0x20, 0x13, 0x00, 0x0d, 
    405 0xec, 0xca, 0x05, 0x7f, 0x20, 0x01, 0x00, 0x0d, 
    406 0xec, 0xc9, 0x03, 0x41, 0x00, 0x00, 0x00, 0x00, 
    407 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    408 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    409 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    410 0x00, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 
    411 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    412 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    413 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    414 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    415 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    416 #if FIP_VERSION_1
    417 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0xfc, 
    418 #else
    419 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x0e, 0xfc, 
    420 #endif
    421 0x00, 0xb8, 0x02, 0x3c, 0x2e, 0x53, 0xe3, 0xe3 };
    422 
    423 unsigned char FDISC_Request[] = {
    424 0x00, 0x0D, 0xEC, 0xCD, 0xFD, 0x00, 0x00, 0xC0, 
    425 0xDD, 0x12, 0xAB, 0x1D, 0x81, 0x00, 0x60, 0x04, 
    426 0x89, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    427 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2E, 
    428 0x22, 0xFF, 0xFF, 0xFE, 0x00, 0x00, 0x00, 0x00, 
    429 0x01, 0x29, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 
    430 0x00, 0x19, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 
    431 0x51, 0x00, 0x00, 0x00, 0x20, 0x20, 0x00, 0x28, 
    432 0x80, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 
    433 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x10, 
    434 0x18, 0x44, 0x2f, 0x56, 0x20, 0x00, 0x00, 0x10, 
    435 0x18, 0x44, 0x2f, 0x55, 0x00, 0x00, 0x00, 0x00, 
    436 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    437 0x00, 0x01, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 
    438 0x00, 0x00, 0x08, 0x00, 0x00, 0xFF, 0x00, 0x0C, 
    439 0x00, 0x01, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 
    440 0x00, 0x00, 0x08, 0x00, 0x00, 0xFF, 0x00, 0x00, 
    441 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    442 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    443 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    444 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
    445 0x00, 0x00, 0x00, 0x00, 0xa0, 0x5c, 0x1e, 0xff, 
    446 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
    447 
    448 #define FIP_OPCODE_DISCOVERY 0x1
    449 #define FIP_SUBCODE_DISCOVERY_SOLICITION   0x1
    450 #define FIP_SUBCODE_DISCOVERY_ADVERTISMENT 0x2
    451 
    452 
    453 #define FIP_OPCODE_FLOGI 0x2
    454 #define FIP_SUBCODE_FLOGI_REQUEST 0x1
    455 #define FIP_SUBCODE_FLOGI_REPLY   0x2
    456 
    457 #define FIP_OPCODE_VLAN 0x4
    458 #define FIP_SUBCODE_VLAN_REQUEST 0x1
    459 #define FIP_SUBCODE_VLAN_REPLY 0x2
    460 
    461 #if FIP_VERSION_1
    462 #define FIP_OPCODE_KEEPALIVE 0x3
    463 #define FIP_SUBCODE_KEEPALIVE_REQUEST 0x1
    464 #define FIP_SUBCODE_KEEPALIVE_REPLY 0x2
    465 #endif
    466 
    467 #define FCOE_FIP_OPCODE(pkt) \
    468     ((uint16) ((BCM_PKT_VLAN_PTR(pkt)[8] << 8) | (BCM_PKT_VLAN_PTR(pkt)[9])))
    469 
    470 #define FCOE_FIP_SUBCODE(pkt) \
    471     ((uint8)(BCM_PKT_VLAN_PTR(pkt)[11]))
    472 
    473 #define FCOE_FIP_DESC_LEN(pkt) \
    474     ((uint16) ((BCM_PKT_VLAN_PTR(pkt)[13] << 8) | (BCM_PKT_VLAN_PTR(pkt)[12])))
    475 
    476 
    477 #define FCOE_R_CTL(pkt) \
    478     ((uint8)(BCM_PKT_VLAN_PTR(pkt)[20]))
    479 
    480 /* 
    481  * 1> All FCOE frames origniation from Source NPort Id, will be routed to dest fc
    482  * port.
    483  * 2> All FCOE frames from dest_fc port with src nport ID will be routed to
    484  * src_eth_port
    485  */
    486 STATIC int
    487 fcoe_add_nport_route(int unit, int src_eth_port, int src_nport_id, int dest_fc_port)
    488 {
    489     bcm_field_qset_t qset;
    490     bcm_field_group_t group;
    491     bcm_field_entry_t entry;
    492     bcm_field_action_t action = bcmFieldActionRedirect;
    493     bcm_field_stat_t stat_entry = bcmFieldStatPackets;
    494     int stat_id;
    495     bcm_gport_t gport[2] = {0x8000007, 0x8000009}; /* xe2, xe4 */
    496 
    497 #if FIP_VERSION_1
    498     bcm_mac_t mac1 = {0x00, 0xfc, 0x00, 0x00, 0x00, 0x00};
    499 #else
    500     bcm_mac_t mac1 = {0x0e, 0xfc, 0x00, 0x00, 0x00, 0x00};
    501 #endif
    502     bcm_mac_t mac2 = {0x00, 0x10, 0x18, 0x01, 0x02, 0x03};
    503     bcm_mac_t mac_mask = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
    504 
    505     bcm_port_gport_get(unit, dest_fc_port, &gport[0]);
    506     bcm_port_gport_get(unit, src_eth_port, &gport[1]);
    507 
    508     mac1[3] = (src_nport_id & 0xff0000) >> 16; 
    509     mac1[4] = (src_nport_id & 0x00ff00) >> 8; 
    510     mac1[5] = (src_nport_id & 0x0000ff); 
    511 
    512     cli_out("fcoe_add_nport_route: src_eth_port = %d, src_nport_id = %x, dest_fc_port = %d\n",  src_eth_port, src_nport_id, dest_fc_port);
    513 
    514     BCM_FIELD_QSET_INIT(qset);
    515     BCM_FIELD_QSET_ADD(qset, bcmFieldQualifySrcMac);
    516     BCM_FIELD_QSET_ADD(qset, bcmFieldQualifyDstMac);
    517 
    518     /* group create */
    519     bcm_field_group_create(unit, qset, 1, &group);
    520 
    521     /* Entry1: Redirect to xe4 */
    522     bcm_field_entry_create(unit, group, &entry);
    523     bcm_field_qualify_DstMac(0, entry, mac1, mac_mask);
    524     bcm_field_qualify_SrcMac(0, entry, mac2, mac_mask);
    525     bcm_field_action_add(unit, entry, action, -1, gport[1]); 
    526     bcm_field_stat_create(0, group, 1, &stat_entry, &stat_id);
    527     bcm_field_entry_stat_attach(0, entry, stat_id);
    528     cli_out("EID:%d STATID:%d\n", entry, stat_id);
    529     bcm_field_entry_install(unit, entry);
    530 
    531     /* Entry2: Redirect to xe2 */
    532     bcm_field_entry_create(unit, group, &entry);
    533     bcm_field_qualify_SrcMac(0, entry, mac1, mac_mask);
    534     bcm_field_qualify_DstMac(0, entry, mac2, mac_mask);
    535     bcm_field_action_add(unit, entry, action, -1, gport[0]);
    536     bcm_field_stat_create(0, group, 1, &stat_entry, &stat_id);
    537     bcm_field_entry_stat_attach(0, entry, stat_id);
    538     cli_out("EID:%d STATID:%d\n", entry, stat_id);
    539     bcm_field_entry_install(unit, entry);
    540 
    541     return BCM_E_NONE;
    542 }
    543 
    544 STATIC int
    545 fcoe_tx_pkt_helper(int unit, int port, unsigned char *pkt_data, int len)
    546 {
    547     bcm_pkt_t pkt;
    548     int rv = BCM_E_FAIL;
    549     pbmp_t  tx_pbmp, tx_upbmp;
    550     int pktSize;
    551 
    552     bcm_pkt_t_init(&pkt);
    553     pktSize = len;
    554   
    555     BCM_PBMP_PORT_SET(tx_pbmp, port);
    556     BCM_PBMP_PORT_SET(tx_upbmp, port);
    557 
    558     /* alloc packet body */    
    559     pkt.alloc_ptr = (uint8 *)soc_cm_salloc(unit, pktSize, "LLDP"); 
    560   
    561     if (pkt.alloc_ptr == NULL) {        
    562         cli_out("WARNING: Could not alloc tx buffer. Memory error.\n");    
    563         return rv;
    564     } else {        
    565         pkt._pkt_data.data = pkt.alloc_ptr;        
    566         pkt.pkt_data = &pkt._pkt_data;        
    567         pkt.blk_count = 1;        
    568         pkt._pkt_data.len = pktSize;
    569     }
    570     /* packet re-init */    
    571     sal_memset(pkt.pkt_data[0].data, 0, pkt.pkt_data[0].len);        
    572   
    573     /* setup the packet */    
    574     pkt.flags &= ~BCM_TX_CRC_FLD;    
    575     pkt.flags |= BCM_TX_CRC_REGEN; 
    576     pkt.flags |= BCM_PKT_F_NO_VTAG; 
    577   
    578     /* assign pbmp */    
    579     sal_memcpy((uint8 *)&pkt.tx_pbmp, (uint8 *)&tx_pbmp, sizeof(bcm_pbmp_t));    
    580     sal_memcpy((uint8 *)&pkt.tx_upbmp, (uint8 *)&tx_upbmp, sizeof(bcm_pbmp_t));
    581   
    582     sal_memcpy(pkt.pkt_data[0].data, pkt_data, pktSize );
    583     if ((rv = bcm_tx(unit, &pkt, NULL)) != BCM_E_NONE) {        
    584         LOG_ERROR(BSL_LS_SOC_COMMON,
    585                   (BSL_META_U(unit,
    586                               "bcm_tx failed: Unit %d: %s\n"),
    587                               unit, bcm_errmsg(rv)));        
    588         return rv;
    589      }
    590      soc_cm_sfree(unit, pkt.alloc_ptr );
    591      return BCM_E_NONE; 
    592 }
    593 
    594 /* Send VLAN response */
    595 STATIC int
    596 fip_tx_vlan_response(bcm_pkt_t *info)
    597 {
    598     int rv = 0;
    599     enet_hdr_t   *ep = NULL;    
    600     ep = (enet_hdr_t *)(info->pkt_data[0].data);
    601     ENET_SET_MACADDR(FIP_VLAN_Response, ep->en_shost);
    602     if ((rv = fcoe_tx_pkt_helper(info->unit, info->src_port, 
    603                            FIP_VLAN_Response, sizeof(FIP_VLAN_Response))) !=
    604                            BCM_E_NONE) {
    605         LOG_ERROR(BSL_LS_SOC_COMMON,
    606                   (BSL_META_U(info->unit,
    607                               "bcm_tx failed: Unit %d: %s\n"),
    608                               info->unit, bcm_errmsg(rv)));
    609         return BCM_E_FAIL;
    610     }
    611     return BCM_E_NONE; 
    612 }
    613 
    614 
    615 STATIC int
    616 fip_tx_advertisement(bcm_pkt_t *info)
    617 {
    618     int rv = 0;
    619     enet_hdr_t   *ep = NULL;    
    620     ep = (enet_hdr_t *)(info->pkt_data[0].data);
    621     ENET_SET_MACADDR(FIP_Advertisement, ep->en_shost);
    622     FIP_Advertisement[27] = 0x07; /* response to solicit */
    623     if ((rv = fcoe_tx_pkt_helper(info->unit, info->src_port, 
    624                            FIP_Advertisement, sizeof(FIP_Advertisement))) !=
    625                            BCM_E_NONE) {
    626         LOG_ERROR(BSL_LS_SOC_COMMON,
    627                   (BSL_META_U(info->unit,
    628                               "bcm_tx failed: Unit %d: %s\n"),
    629                               info->unit, bcm_errmsg(rv)));
    630         return BCM_E_FAIL;
    631     }
    632     return BCM_E_NONE; 
    633 }
    634 
    635 
    636 
    637 STATIC int 
    638 fcoe_get_unused_fip_flogi_entry(int *entry)
    639 {
    640     int i;
    641     for (i = 0; i < FCOE_MAX_FIP_FLOGI; i++) {
    642         if (fip_flogi_pending[i].used == 0) {
    643             break;
    644         }
    645     }
    646     if (i < FCOE_MAX_FIP_FLOGI) {
    647         *entry = i;
    648         return BCM_E_NONE;
    649     }
    650     return BCM_E_FAIL;
    651 }
    652 
    653 
    654 STATIC int 
    655 fcoe_get_fip_flogi_entry(uint16 oxid, int *entry)
    656 {
    657     int i;
    658     for (i = 0; i < FCOE_MAX_FIP_FLOGI; i++) {
    659         if ((fip_flogi_pending[i].used == 1) &&
    660             (oxid == fip_flogi_pending[i].oxid)) {
    661             break;
    662         }
    663     }
    664     if (i < FCOE_MAX_FIP_FLOGI) {
    665         *entry = i;
    666         return BCM_E_NONE;
    667     }
    668     return BCM_E_FAIL;
    669 }
    670 
    671 
    672 
    673 STATIC int
    674 fip_handle_flogi(bcm_pkt_t *info)
    675 {
    676     enet_hdr_t   *ep = NULL;    
    677     int rv = 0;
    678     int entry;
    679 
    680     unsigned char *fdisc_req;
    681 
    682     fdisc_req = sal_alloc(sizeof(FDISC_Request), "Fdisc copy");
    683     if (fdisc_req == NULL) {
    684         cli_out("unable to allocate memory for FDISC\n");
    685         return BCM_E_FAIL;
    686     }
    687 
    688     /* Update pending FIP FLOGI */
    689     /* Store SMAC, port on which FIP was received */
    690     if (fcoe_get_unused_fip_flogi_entry(&entry) != BCM_E_NONE) {
    691         cli_out("fip_handle_flogi: Failed to get unused entry \n");
    692         return BCM_E_FAIL;
    693     }
    694     
    695     ep = (enet_hdr_t *)(info->pkt_data[0].data);    
    696 
    697     /* Make a copy of FDISC */
    698     sal_memcpy(fdisc_req, FDISC_Request, sizeof(FDISC_Request)); 
    699 
    700     /* Copy the FIP FLOGI to the FDISC Request before sending */
    701     sal_memcpy(fdisc_req + 32, info->pkt_data[0].data + 32,   /* Where FCframe starts */
    702                                    info->tot_len - 32 - 16);
    703     FDISC_Request[56] = 0x51; /* FDISC request */
    704     fdisc_req[56] = 0x51;
    705 
    706     ENET_SET_MACADDR(fip_flogi_pending[entry].sa, ep->en_shost);
    707     fip_flogi_pending[entry].unit = info->unit;
    708     fip_flogi_pending[entry].port = info->src_port;
    709     fip_flogi_pending[entry].oxid = *(uint16 *)(fdisc_req + 48); /* mark entry as used */
    710     fip_flogi_pending[entry].used = 1; /* mark entry as used */
    711 
    712     cli_out("FIP FLOGI packet: time=0x%x, OXID=0x%4x, CNA port=%d\n", 
    713             sal_time_usecs(), fip_flogi_pending[entry].oxid, fip_flogi_pending[entry].port);
    714     cli_out("SRCMAC: 0x%04x%04x%04x \n",
    715             *(uint16 *)(fip_flogi_pending[entry].sa + 0),
    716             *(uint16 *)(fip_flogi_pending[entry].sa + 2),
    717             *(uint16 *)(fip_flogi_pending[entry].sa + 4));
    718 
    719 
    720     
    721     /* send FDISC to FC port */
    722     if ((rv = fcoe_tx_pkt_helper(info->unit, fcoe_fc_port, 
    723                            fdisc_req, sizeof(FDISC_Request))) !=
    724                            BCM_E_NONE) {
    725         LOG_ERROR(BSL_LS_SOC_COMMON,
    726                   (BSL_META_U(info->unit,
    727                               "bcm_tx failed: Unit %d: %s\n"),
    728                               info->unit, bcm_errmsg(rv)));
    729         sal_free(fdisc_req);
    730         return BCM_E_FAIL;
    731     }
    732     
    733     sal_free(fdisc_req);
    734     return BCM_E_NONE; 
    735 }
    736 
    737 
    738 /* Handle FIP packet */
    739 STATIC int
    740 fcoe_handle_fip_packet(bcm_pkt_t *info)
    741 {
    742     uint16 opcode;
    743     opcode = FCOE_FIP_OPCODE(info);
    744     /* received a VLAN discovery */
    745     if (opcode == FIP_OPCODE_VLAN) {
    746         if (FCOE_FIP_SUBCODE(info) != FIP_SUBCODE_VLAN_REQUEST) {
    747             cli_out("Invalid FIP-VLAN Packet received \n");
    748         } else {
    749             fip_tx_vlan_response(info);
    750         }
    751     }
    752 
    753     /* received a Solicitation */
    754     if (opcode == FIP_OPCODE_DISCOVERY) {
    755         if (FCOE_FIP_SUBCODE(info) != FIP_SUBCODE_DISCOVERY_SOLICITION) {
    756             cli_out("Invalid FIP-Discovery Packet received \n");
    757         } else {
    758             fip_tx_advertisement(info);
    759         }
    760     }
    761 
    762     /* Received a FLOGI frame */
    763     if (opcode == FIP_OPCODE_FLOGI) {
    764         fip_handle_flogi(info);
    765     }
    766 
    767     return BCM_E_NONE;
    768 }
    769 
    770 #define FCOE_CMD_CODE(pkt) \
    771     ((uint8)(BCM_PKT_VLAN_PTR(pkt)[44]))
    772 
    773 #define FCOE_FC_BB_CREDIT(pkt) \
    774     ((uint16) ((BCM_PKT_VLAN_PTR(pkt)[51] << 8) | (BCM_PKT_VLAN_PTR(pkt)[50])))
    775 
    776 /* char fcf_nport_id[3];  NPV nport ID to use */
    777 uint16 bb_credit;      /* FC credit of remote link */
    778 int fc_nport_init = 0; /* NPV port is not initailized */
    779 
    780 STATIC int
    781 fip_tx_els_reply(int unit, bcm_pkt_t *info)
    782 {
    783     bcm_pkt_t pkt;
    784     enet_hdr_t   *ep = NULL;    
    785     int rv = 0;
    786     int pktSize;
    787     int entry;
    788     uint16 oxid;
    789     int nport_id; 
    790 
    791     bcm_pkt_t_init(&pkt);
    792     pktSize = sizeof(FIP_FLOGI_Response); /* Size of the above packet */
    793   
    794     /* alloc packet body */    
    795     pkt.alloc_ptr = (uint8 *)soc_cm_salloc(info->unit, pktSize, "FIP_FLOGI_Response"); 
    796   
    797     if (pkt.alloc_ptr == NULL) {        
    798         cli_out("WARNING: Could not alloc tx buffer. Memory error.\n");    
    799     } else {        
    800         pkt._pkt_data.data = pkt.alloc_ptr;        
    801         pkt.pkt_data = &pkt._pkt_data;        
    802         pkt.blk_count = 1;        
    803         pkt._pkt_data.len = pktSize;
    804     }
    805     /* packet re-init */    
    806     sal_memset(pkt.pkt_data[0].data, 0, pkt.pkt_data[0].len);        
    807     ep = (enet_hdr_t *)(pkt.pkt_data[0].data);    
    808   
    809     /* setup the packet */    
    810     pkt.flags &= ~BCM_TX_CRC_FLD;    
    811     pkt.flags |= BCM_TX_CRC_REGEN; 
    812     pkt.flags |= BCM_PKT_F_NO_VTAG; 
    813 
    814     oxid = *(uint16 *)(info->pkt_data[0].data + 48); /* mark entry as used */
    815     if (fcoe_get_fip_flogi_entry(oxid, &entry) != BCM_E_NONE) {
    816         cli_out("Unknown OXID = %x\n", oxid);
    817         return BCM_E_FAIL;
    818     }
    819     cli_out("ELS reply packet: time=0x%x, OXID=0x%4x, CNA port=%d\n", sal_time_usecs(), oxid, fip_flogi_pending[entry].port);
    820     cli_out("DSTMAC: 0x%04x%04x%04x \n",
    821             *(uint16 *)(fip_flogi_pending[entry].sa + 0),
    822             *(uint16 *)(fip_flogi_pending[entry].sa + 2),
    823             *(uint16 *)(fip_flogi_pending[entry].sa + 4));
    824 
    825     /* assign pbmp */    
    826     BCM_PBMP_PORT_SET(pkt.tx_pbmp, fip_flogi_pending[entry].port);
    827     BCM_PBMP_PORT_SET(pkt.tx_upbmp, fip_flogi_pending[entry].port);
    828 
    829     sal_memcpy(pkt.pkt_data[0].data, FIP_FLOGI_Response, pktSize);
    830 
    831     /* assign mac addr */    
    832     ENET_SET_MACADDR(ep->en_dhost, fip_flogi_pending[entry].sa);    
    833     ENET_SET_MACADDR(ep->en_shost, fcf_sa_mac);    
    834     /* Overwrite the response */
    835     /* Copy only FC frame; FIP header = 16bytes. 
    836      * FCoE Header = 16 Bytes, + Eth Header + VLAN = 16 bytes.
    837      */
    838     sal_memcpy(pkt.pkt_data[0].data + 32, BCM_PKT_VLAN_PTR(info) + 20, info->tot_len - 32 - 12);
    839 
    840     /* Construct FPMA */
    841     sal_memcpy(pkt.pkt_data[0].data + info->tot_len - 7, pkt.pkt_data[0].data + 33, 3);
    842 
    843     if ((rv = bcm_tx(info->unit, &pkt, NULL)) != BCM_E_NONE) {        
    844         LOG_ERROR(BSL_LS_SOC_COMMON,
    845                   (BSL_META_U(unit,
    846                               "bcm_tx failed: Unit %d: %s\n"),
    847                               info->unit, bcm_errmsg(rv)));
    848         return rv;
    849     }
    850 
    851     /* Add route in FP */
    852     nport_id = 0;
    853     sal_memcpy(((char *)&nport_id)+1, pkt.pkt_data[0].data + 33, 3);
    854     fcoe_add_nport_route(unit, fip_flogi_pending[entry].port,
    855                                nport_id, 
    856                                info->src_port);
    857 
    858     fip_flogi_pending[entry].used = 0;
    859     soc_cm_sfree(info->unit, pkt.alloc_ptr);
    860     return BCM_E_NONE; 
    861 }
    862 
    863 STATIC int
    864 fcoe_handle_flogi_response(int unit, bcm_pkt_t *info)
    865 {
    866     uint16 oxid; 
    867     bcm_mac_t  fcf_sa_mac = {0x00,0x10,0x18,0x01,0x02,0x03};
    868     int entry;
    869     int bbc;
    870     bcm_fcmap_port_config_t cfg;
    871 
    872     /* Get OXID */
    873     oxid = *(uint16 *)((info->pkt_data[0].data) + 48);    
    874     if (fcoe_get_fip_flogi_entry(oxid, &entry) != BCM_E_NONE) {
    875         cli_out("Unknown OXID = %x\n", oxid);
    876         return BCM_E_FAIL;
    877     }
    878     if (ENET_CMP_MACADDR(fip_flogi_pending[entry].sa, fcf_sa_mac) == 0) {
    879         /* Flogi reply from FC switch to my originated FLOGI */
    880         /* store the nport ID to use */
    881         /* BB Credit of the link partner */
    882         if (FCOE_CMD_CODE(info) == 0x02) { /* Accept */
    883             /* sal_memcpy(fcf_nport_id, BCM_PKT_VLAN_PTR(info) + 21, 3); */
    884             bb_credit = FCOE_FC_BB_CREDIT(info);
    885         } else {  /* Reject */
    886         }
    887         cli_out("ACC for FLOGI \n");
    888         fip_flogi_pending[entry].used = 0;
    889 
    890         /* Retrive BB Credits and program to into the device */
    891         bbc = *((info->pkt_data[0].data) + 63);    
    892         cli_out("BBC = %x\n", bbc);
    893 
    894         /* Get FC port Configuration details */
    895         memset(&cfg, 0, sizeof(cfg));
    896         if (bcm_fcmap_port_config_get(unit, info->src_port, &cfg) != BCM_E_NONE) {
    897             cli_out("Port Configuration retrive failed\n");
    898             return BCM_E_FAIL;
    899         }
    900 
    901         if (is_mt2) {
    902             /* FIP Server running on MT2 */
    903             /* Clear action mask and set only required parameters */
    904             cfg.action_mask &= ~BCM_FCMAP_ATTR_ALL_MASK;
    905 
    906             cfg.action_mask |= BCM_FCMAP_ATTR_TX_BB_CREDITS_MASK;
    907         } else {
    908             cfg.action_mask |= BCM_FCMAP_ATTR_ALL_MASK;
    909             cfg.action_mask2 |= BCM_FCMAP_ATTR2_ALL_MASK;
    910         }
    911 
    912         cfg.tx_buffer_to_buffer_credits = bbc;
    913         if (bcm_fcmap_port_config_selective_set(unit, info->src_port, &cfg) != BCM_E_NONE) {
    914             cli_out("Port Configuration Set failed\n");
    915             return BCM_E_FAIL;
    916         }
    917 
    918         /* FC port Configurations */
    919         _print_fcmap_cfg(&cfg);
    920 
    921     } else {
    922         /* 
    923          * The FLOGI response is for a CNA initiated FLOGI.
    924          * Package the FLOGI response and send back to CNA
    925          */
    926         /* Extract only FC frame from the response */
    927         /* DA + SA + VLAN + FCOEHdr = 32 */
    928         /* FC crc + FCoE trailer + FCS  = 12 */
    929         /* sal_memcpy(pdata, BCM_PKT_VLAN_PTR(info) + 20, info->tot_len - 32 - * 12); */
    930 
    931         if (fip_tx_els_reply(unit, info) != BCM_E_NONE) {
    932             return BCM_E_FAIL;
    933         }
    934 
    935         /* Initialize PFC on all ports */
    936         if (bcm_port_control_set(0, fip_flogi_pending[0].port, 
    937                                  bcmPortControlPFCReceive, 1) != BCM_E_NONE)
    938         {  
    939             cli_out("Enabling PFC Receive failed...\n");
    940             return BCM_E_FAIL;
    941         }
    942         if (bcm_port_control_set(0, fip_flogi_pending[0].port, 
    943                                  bcmPortControlPFCTransmit, 1) != BCM_E_NONE)
    944         {  
    945             cli_out("Enabling PFC Transmit failed...\n");
    946             return BCM_E_FAIL;
    947         }
    948     }
    949     return BCM_E_NONE;
    950 }
    951 
    952 
    953 STATIC int
    954 fcoe_handle_fcoe_packet(int unit, bcm_pkt_t *info)
    955 {
    956     /* we should only receive Accept/Reject in FCoE all other are invlaid */
    957     if (FCOE_R_CTL(info) == 0x23) {  /* ELS reply */
    958         /* If DMAC is my DA then save the Nport ID */
    959         fcoe_handle_flogi_response(unit, info);
    960     } else {
    961         cli_out("Error: fcoe_handle_fcoe_packet: Received FCoE Packet which is not ELS reply...\n");
    962         return BCM_E_FAIL;
    963     }
    964     return BCM_E_NONE;
    965 }
    966 
    967 /* Transmit LLDP to CNA */
    968 STATIC int 
    969 fcoe_transmit_LLDP(bcm_pkt_t *info)
    970 {
    971     int rv = 0;
    972     if ((rv = fcoe_tx_pkt_helper(info->unit, info->src_port, lldp, sizeof(lldp))) !=
    973                            BCM_E_NONE) {
    974         LOG_ERROR(BSL_LS_SOC_COMMON,
    975                   (BSL_META_U(info->unit,
    976                               "bcm_tx failed: Unit %d: %s\n"),
    977                               info->unit, bcm_errmsg(rv)));
    978         return BCM_E_FAIL;
    979     }
    980     return BCM_E_NONE; 
    981 }
    982 
    983 STATIC int
    984 fcoe_handle_lldp_packet(bcm_pkt_t *info)
    985 {
    986     /* Transmit LLDP to CNA */
    987     if (fcoe_transmit_LLDP(info) != BCM_E_NONE) {
    988         cli_out("LLDP to CNA failed \n");
    989         return BCM_E_FAIL;
    990     }
    991     return BCM_E_NONE;
    992 }
    993 
    994 bcm_rx_t
    995 fcoe_rx_callback(int unit, bcm_pkt_t *info, void *cookie)
    996 /*
    997  * Function:    fcoe_rx_callback
    998  * Purpose:     This is the callback handler for the packets forwarded to
    999  *              the CMIC.
   1000  * Parameters:
   1001  *              unit - device code.
   1002  *              info - received packet description structure.
   1003  *              cookie - lw - pointer to lb work.
   1004  * Returns:     0 - success, -1 failed.
   1005  * Notes:
   1006  *       Called in INTERRUPT CONTEXT
   1007  */
   1008 {
   1009     uint8 *pkt_data;
   1010     uint16 eth_type = 0;
   1011 
   1012     pkt_data = BCM_PKT_DMAC(info); /* Pointer to Destination MAC */
   1013 
   1014     if (BCM_PKT_TAG_PROTOCOL(info) != 0x8100) { 
   1015         cli_out("Untagged packet ...\n");
   1016         /* untagged packet */
   1017         if (BCM_PKT_TAG_PROTOCOL(info) == 0x8906) { /* FCoE Packet */
   1018             cli_out("fcoe packet \n");
   1019             fcoe_handle_fcoe_packet(unit, info);
   1020         }
   1021         if (BCM_PKT_TAG_PROTOCOL(info) == 0x8914) { /* FIP Packet */
   1022             cli_out("FIP packet \n");
   1023             fcoe_handle_fip_packet(info);
   1024         }
   1025         if (BCM_PKT_TAG_PROTOCOL(info) == 0x88cc) { /* LLDP Packet */
   1026             cli_out("lldp packet \n");
   1027             fcoe_handle_lldp_packet(info);
   1028         }
   1029     } else {
   1030         eth_type = *(uint16 *)(pkt_data + 16);
   1031         if (eth_type == 0x8906) { /* FCoE Packet */
   1032             fcoe_handle_fcoe_packet(unit, info);
   1033         }
   1034         if (eth_type == 0x8914) { /* FIP Packet */
   1035             fcoe_handle_fip_packet(info);
   1036         }
   1037         if (eth_type == 0x88cc) { /* LLDP Packet */
   1038             fcoe_handle_lldp_packet(info);
   1039         }
   1040 
   1041     }
   1042     return BCM_RX_HANDLED;
   1043 }
   1044 
   1045 /* RX Init */
   1046 STATIC int 
   1047 fcoe_rx_init(int unit)
   1048 {
   1049     int rv = BCM_E_NONE;
   1050     bcm_rx_cfg_t rx_cfg;
   1051 
   1052     if (BCM_RX_INIT_DONE(unit)) {
   1053         cli_out("fcoe_rx_init:  RX already running (u=%d)\n", unit);
   1054         return BCM_E_INIT;
   1055     }
   1056 
   1057     /* Get current configuration */
   1058     bcm_rx_cfg_init(unit);   /* Re-init in case in bad state */
   1059     bcm_rx_cfg_get(unit, &rx_cfg);
   1060     rx_cfg.global_pps = BCM_RX_RATE_NOLIMIT;
   1061     rx_cfg.chan_cfg[BCM_RX_CHAN_DFLT].rate_pps = BCM_RX_RATE_NOLIMIT;
   1062     rv = bcm_rx_start(unit, &rx_cfg);
   1063 
   1064     if (BCM_E_NONE != rv) {
   1065         cli_out("fcoe_rx_init:" "rx_start failed: %s\n", bcm_errmsg(rv));
   1066         return rv;
   1067     }
   1068 
   1069     rv = bcm_rx_register(unit, "FCOE NPV Diag", fcoe_rx_callback,
   1070                          BCM_RX_PRIO_MAX, (void *)&unit,
   1071                          BCM_RCO_F_ALL_COS);
   1072     if (BCM_E_NONE != rv) {
   1073         cli_out("fcoe_rx_init:"
   1074                 "rx_register failed: %s\n", bcm_errmsg(rv));
   1075         return rv;
   1076     }
   1077     return BCM_E_NONE;
   1078 }
   1079 
   1080 
   1081 static void
   1082 fcoe_flogi_timer(void *p_owner, void *p2, void *p3, void *p4, void *p5)
   1083 {
   1084     fip_flogi_t *p_fip_flogi = (fip_flogi_t *)p_owner;
   1085     int rv = 0;
   1086 
   1087     if (p_fip_flogi->used) {
   1088         cli_out("fcoe_flogi_timer: OXID = %x\n", p_fip_flogi->oxid);
   1089         if ((rv = fcoe_tx_pkt_helper(p_fip_flogi->unit, p_fip_flogi->port, 
   1090                                FLOGI_Request, sizeof(FLOGI_Request))) !=
   1091                                BCM_E_NONE) {
   1092             LOG_ERROR(BSL_LS_SOC_COMMON,
   1093                       (BSL_META("Couldn't send FLOGI Unit %d: %s\n"),                   
   1094                        p_fip_flogi->unit, bcm_errmsg(rv)));
   1095             return;
   1096         }
   1097         
   1098         sal_dpc_time(SECOND_USEC, fcoe_flogi_timer, p_owner, 0, 0, 0, 0);
   1099     }
   1100 }
   1101 
   1102 /* Transmit FLOGI to the FC switch */
   1103 STATIC int 
   1104 fcoe_transmit_FLOGI(int unit, int port)
   1105 {
   1106     int rv = 0;
   1107     int entry;
   1108 
   1109     if (fcoe_get_unused_fip_flogi_entry(&entry) != BCM_E_NONE) {
   1110         cli_out("fcoe_transmit_FLOGI: Failed to get unused entry \n");
   1111         return BCM_E_FAIL;
   1112     }
   1113 
   1114     ENET_SET_MACADDR(fip_flogi_pending[entry].sa, fcf_sa_mac);   
   1115     fip_flogi_pending[entry].unit = unit;
   1116     fip_flogi_pending[entry].port = port;
   1117     fip_flogi_pending[entry].oxid = *(uint16 *)(FLOGI_Request + 48); /* mark entry as used */
   1118     fip_flogi_pending[entry].used = 1; /* mark entry as used */
   1119 
   1120     cli_out("OXID = %x\n", fip_flogi_pending[entry].oxid);
   1121     if ((rv = fcoe_tx_pkt_helper(unit, port, 
   1122                            FLOGI_Request, sizeof(FLOGI_Request))) !=
   1123                            BCM_E_NONE) {
   1124         LOG_ERROR(BSL_LS_SOC_COMMON,
   1125                   (BSL_META_U(unit,
   1126                               "Couldn't send FLOGI Unit %d: %s\n"),
   1127                               unit, bcm_errmsg(rv)));
   1128         return rv;
   1129     }
   1130 
   1131     sal_dpc_time(SECOND_USEC, fcoe_flogi_timer, &fip_flogi_pending[entry], 0, 0, 0, 0);
   1132     return BCM_E_NONE; 
   1133 }
   1134 
   1135 
   1136 
   1137 
   1138 STATIC int 
   1139 fcoe_add_donot_learn_fcoe(int unit, int port)
   1140 {
   1141     bcm_field_qset_t qset;
   1142     bcm_field_group_t group;
   1143     bcm_field_entry_t entry;
   1144     bcm_field_stat_t stat_entry = bcmFieldStatPackets;
   1145     int stat_id;
   1146 
   1147     /* qset */
   1148     BCM_FIELD_QSET_INIT(qset);
   1149     BCM_FIELD_QSET_ADD(qset, bcmFieldQualifyStageLookup);
   1150     BCM_FIELD_QSET_ADD(qset, bcmFieldQualifyEtherType);
   1151 
   1152     /* group create */
   1153     BCM_IF_ERROR_RETURN(
   1154         bcm_field_group_create(unit, qset, BCM_FIELD_GROUP_PRIO_ANY, &group));
   1155 
   1156     /* EtherType == 0x8914 */
   1157     BCM_IF_ERROR_RETURN(
   1158         bcm_field_entry_create(unit, group, &entry));
   1159     BCM_IF_ERROR_RETURN(
   1160         bcm_field_qualify_EtherType(0, entry, 0x8914, 0xffff));
   1161     BCM_IF_ERROR_RETURN(
   1162         bcm_field_action_add(unit, entry, bcmFieldActionDoNotLearn, 0,0)); 
   1163     BCM_IF_ERROR_RETURN(
   1164         bcm_field_action_add(unit, entry, bcmFieldActionCopyToCpu, 0,0)); 
   1165     BCM_IF_ERROR_RETURN(
   1166         bcm_field_stat_create(0, group, 1, &stat_entry, &stat_id));
   1167     BCM_IF_ERROR_RETURN(
   1168         bcm_field_entry_stat_attach(0, entry, stat_id));
   1169     cli_out("EID:%d STATID:%d\n", entry, stat_id);
   1170     BCM_IF_ERROR_RETURN(
   1171         bcm_field_entry_install(unit, entry));
   1172 
   1173     /* EtherType == 0x8906 */
   1174     BCM_IF_ERROR_RETURN(
   1175         bcm_field_entry_create(unit, group, &entry));
   1176     BCM_IF_ERROR_RETURN(
   1177         bcm_field_qualify_EtherType(0, entry, 0x8906, 0xffff));
   1178     BCM_IF_ERROR_RETURN(
   1179         bcm_field_action_add(unit, entry, bcmFieldActionDoNotLearn, 0,0)); 
   1180     BCM_IF_ERROR_RETURN(
   1181         bcm_field_stat_create(0, group, 1, &stat_entry, &stat_id));
   1182     BCM_IF_ERROR_RETURN(
   1183         bcm_field_entry_stat_attach(0, entry, stat_id));
   1184     cli_out("EID:%d STATID:%d\n", entry, stat_id);
   1185 
   1186     BCM_IF_ERROR_RETURN(
   1187         bcm_field_entry_install(unit, entry));
   1188     return BCM_E_NONE;
   1189 }
   1190 
   1191 STATIC int
   1192 fcoe_fabric_trans(int unit, int port)
   1193 {
   1194     int qual_id;
   1195     bcm_field_qset_t qset;                                                                                               
   1196     bcm_field_group_t group;                                                                                             
   1197     bcm_field_entry_t entry;                                                                                             
   1198     bcm_field_action_t action;                                                                                           
   1199     bcm_field_data_qualifier_t data_qualifier;                                                                           
   1200     bcm_field_data_packet_format_t packet_format;                                                                        
   1201     uint8 data[3] = {0xff, 0xff, 0xfe};
   1202     uint8 mask[3] = {0xff, 0xff, 0xff};                                                                                  
   1203     int length = sizeof(data);                                                                                           
   1204     bcm_field_stat_t stat_entry = bcmFieldStatPackets;
   1205     int stat_id;
   1206 
   1207     action = bcmFieldActionCopyToCpu;
   1208     BCM_FIELD_QSET_INIT(qset);                                                                                           
   1209 
   1210     bcm_field_data_qualifier_t_init(&data_qualifier);
   1211 
   1212     data_qualifier.offset_base = bcmFieldDataOffsetBaseFcoeHeader;
   1213     data_qualifier.offset = 19;
   1214     data_qualifier.length = 3;                                                                                           
   1215 
   1216     BCM_IF_ERROR_RETURN(
   1217         bcm_field_data_qualifier_create(unit, &data_qualifier));                                                        
   1218     qual_id = data_qualifier.qual_id;                                                                                    
   1219 
   1220    
   1221     bcm_field_data_packet_format_t_init(&packet_format);                                                                 
   1222 
   1223     packet_format.relative_offset = 0;                                                                                   
   1224     packet_format.l2 = BCM_FIELD_DATA_FORMAT_L2_ETH_II;                                                                  
   1225     packet_format.vlan_tag = BCM_FIELD_DATA_FORMAT_VLAN_SINGLE_TAGGED;
   1226     packet_format.tunnel = BCM_FIELD_DATA_FORMAT_TUNNEL_NONE;
   1227     packet_format.fibre_chan_outer = BCM_FIELD_DATA_FORMAT_FIBRE_CHAN;
   1228 
   1229     BCM_IF_ERROR_RETURN(
   1230         bcm_field_data_qualifier_packet_format_add(unit, qual_id, &packet_format));                                     
   1231 
   1232     BCM_IF_ERROR_RETURN(
   1233         bcm_field_qset_data_qualifier_add(unit, &qset, qual_id));                                                        
   1234     BCM_IF_ERROR_RETURN(
   1235         bcm_field_group_create(unit, qset, 1, &group));                                                                 
   1236     BCM_IF_ERROR_RETURN(
   1237         bcm_field_entry_create(unit, group, &entry));                                                                   
   1238     BCM_IF_ERROR_RETURN(
   1239         bcm_field_qualify_data(unit, entry, qual_id, data, mask, length));                                            
   1240     BCM_IF_ERROR_RETURN(
   1241         bcm_field_action_add(unit, entry, action, 0, 0));                                                             
   1242 
   1243     action = bcmFieldActionDrop;
   1244     BCM_IF_ERROR_RETURN(
   1245         bcm_field_action_add(unit, entry, action, 0, 0));                                                             
   1246     BCM_IF_ERROR_RETURN(
   1247         bcm_field_stat_create(0, group, 1, &stat_entry, &stat_id));
   1248     BCM_IF_ERROR_RETURN(
   1249         bcm_field_entry_stat_attach(0, entry, stat_id));
   1250     cli_out("EID:%d STATID:%d\n", entry, stat_id);
   1251     BCM_IF_ERROR_RETURN(
   1252         bcm_field_entry_install(unit, entry));                                                                          
   1253 
   1254     return BCM_E_NONE;
   1255 }
   1256 
   1257 
   1258 
   1259 #define PRINT_MAC(addr) \
   1260 do {  \
   1261    int i; \
   1262    for (i = 0; i < 6; i++) { \
   1263        cli_out("%x ", addr[i]); \
   1264    } \
   1265    cli_out("\n"); \
   1266 }while(0)
   1267 
   1268 STATIC void 
   1269 _print_fcmap_cfg(bcm_fcmap_port_config_t *cfg) 
   1270 {
   1271     if (cfg != NULL) {
   1272         cli_out("Port configuration\n");
   1273         cli_out("------------------\n");
   1274         cli_out("Port Mode => %d\n", cfg->port_mode);
   1275         cli_out("Port Speed => %d\n", cfg->speed);
   1276         cli_out("TX BBC     => %d\n", cfg->tx_buffer_to_buffer_credits);
   1277         cli_out("RX BBC     => %d\n", cfg->rx_buffer_to_buffer_credits);
   1278         cli_out("R_T_TOV    => %d\n", cfg->r_t_tov);
   1279         cli_out("SRC MAC    => "); PRINT_MAC(cfg->src_mac_addr);
   1280         cli_out("DST MAC    => "); PRINT_MAC(cfg->dst_mac_addr);
   1281         cli_out("VLAN Tag   => %x\n", cfg->vlan_tag);
   1282         cli_out("SRC FPMA Prefix => %x\n", cfg->src_fcmap_prefix);
   1283         cli_out("DST FPMA Prefix => %x\n", cfg->dst_fcmap_prefix);
   1284 
   1285         cli_out("Mapper Length => %d\n", cfg->mapper_len);
   1286 
   1287         cli_out("Ingress Mapper Bypass => %d\n", cfg->ingress_mapper_bypass);
   1288         cli_out("Ingress FC Mapper Table Input => %d\n", cfg->ingress_map_table_input);
   1289         cli_out("Ingress FC CRC Mode => %d\n", cfg->ingress_fc_crc_mode);
   1290         cli_out("Ingress VFT Hdr Processing mode => %d\n", cfg->ingress_vfthdr_proc_mode);
   1291         cli_out("Ingress VLAN TAG Processing mode => %d\n", cfg->ingress_vlantag_proc_mode);
   1292 
   1293         cli_out("Egress Mapper Bypass => %d\n", cfg->egress_mapper_bypass);
   1294         cli_out("Egress FC Mapper Table Input => %d\n", cfg->egress_map_table_input);
   1295         cli_out("Egress FC CRC Mode => %d\n", cfg->egress_fc_crc_mode);
   1296         cli_out("Egress VFT Hdr Processing mode => %d\n", cfg->egress_vfthdr_proc_mode);
   1297         cli_out("Egress VLAN TAG Processing mode => %d\n", cfg->egress_vlantag_proc_mode);
   1298 
   1299         cli_out("SRC MAC Construct Mode => %d\n", cfg->src_mac_construct);
   1300         cli_out("DST MAC Construct Mode => %d\n", cfg->dst_mac_construct);
   1301     }
   1302 }
   1303 
   1304 STATIC void
   1305 fcoe_fip_thread(void *cookie)
   1306 {
   1307     int i, rv;
   1308     bcm_mac_t  fcf_all = {0x01,0x10,0x18,0x01,0x00,0x01}; 
   1309     cli_out("Thread started to send advertisements \n");
   1310     /* Send FIP Discovery Advertisement to all VN_ports */
   1311     while (1) {
   1312         sal_sleep(5);
   1313         /* Loop through all the VN ports */
   1314         for (i = 0; i < FCOE_MAX_FIP_FLOGI; i++) {
   1315             if (fip_flogi_pending[i].used == 0) {
   1316                 continue;
   1317             }
   1318             
   1319             if (ENET_CMP_MACADDR(fip_flogi_pending[i].sa, fcf_sa_mac) == 0) {
   1320                 continue;
   1321             }
   1322                  
   1323             ENET_SET_MACADDR(FIP_Advertisement, fcf_all);
   1324             FIP_Advertisement[27] = 0x05; /* Plain Advertisement */
   1325             /* cli_out("sending advertisements to port %d\n", fip_flogi_pending[i].port); */
   1326             if ((rv = fcoe_tx_pkt_helper(0, fip_flogi_pending[i].port, 
   1327                                    FIP_Advertisement, sizeof(FIP_Advertisement))) !=
   1328                                    BCM_E_NONE) {
   1329                 LOG_ERROR(BSL_LS_SOC_COMMON,
   1330                           (BSL_META("Periodic DISC bcm_tx failed: port %d: %s\n"),
   1331                            fip_flogi_pending[i].port, bcm_errmsg(rv)));
   1332             }
   1333         }
   1334     }
   1335 }
   1336 
   1337 
   1338 int fcoe_start(int unit, int fc_port)
   1339 {
   1340     bcm_fcmap_port_config_t cfg;
   1341     phy_ctrl_t *pc = NULL;
   1342 
   1343     fcoe_fc_port = fc_port;
   1344 
   1345     pc = EXT_PHY_SW_STATE(unit, fc_port);
   1346     if (pc == NULL) {
   1347         return BCM_E_FAIL;
   1348     }
   1349 
   1350     if (phy_is_8806x(pc) == SOC_E_NONE) {
   1351         is_mt2 = 1;
   1352     }
   1353 
   1354     /* Start thread to send advertisements */
   1355     fcoe_thread_id = sal_thread_create("bcmFCOE", SAL_THREAD_STKSZ,
   1356 				     100,
   1357 				     fcoe_fip_thread, NULL);
   1358     if (fcoe_thread_id == SAL_THREAD_ERROR) {
   1359         cli_out("Thread create failed \n");
   1360         return BCM_E_RESOURCE;
   1361     }
   1362     /* Don't learn L2 address for FIP and FCoE frames */
   1363     /* Initialize switch to route FIP frames to CPU */
   1364     cli_out("Adding Do Not Learn L2 for FIP and FCoE Frames\n");
   1365     if (fcoe_add_donot_learn_fcoe(unit, fc_port) != BCM_E_NONE) {
   1366         cli_out("Failed to add donot learn rules\n");
   1367         return BCM_E_FAIL;
   1368     }
   1369 
   1370     /*  All FCoE transactions from 0xFFFFFE go to cpu */
   1371     cli_out("Transactions to Fabric Controller handled by CPU\n");
   1372     if (fcoe_fabric_trans(unit, fc_port) != BCM_E_NONE) {
   1373         cli_out("Failed to add fabric transactions rules....\n");
   1374         return BCM_E_FAIL;
   1375     }
   1376 
   1377     /* Create VLAN on which FCOE/FIP traffic for a given FC port */
   1378     /* Get FC port Configuration details */
   1379     memset(&cfg, 0, sizeof(cfg));
   1380     if (bcm_fcmap_port_config_get(unit, fc_port, &cfg) != BCM_E_NONE) {
   1381         cli_out("Port Configuration retrive failed\n");
   1382         return BCM_E_FAIL;
   1383     }
   1384 
   1385     /* FC port Configurations */
   1386     _print_fcmap_cfg(&cfg);
   1387 
   1388     if (is_mt2) {
   1389         /* FIP Server running on MT2 */
   1390         /* Clear action mask and set only required parameters */
   1391         cfg.action_mask &= ~BCM_FCMAP_ATTR_ALL_MASK;
   1392         cfg.action_mask |= BCM_FCMAP_ATTR_EGRESS_FC_CRC_MODE_MASK |
   1393                            BCM_FCMAP_ATTR_VLAN_TAG_MASK |
   1394                            BCM_FCMAP_ATTR_SRC_MAC_CONSTRUCT_MASK |
   1395                            BCM_FCMAP_ATTR_DST_MAC_CONSTRUCT_MASK ;
   1396     } else {
   1397         /* FIP Server running on MT1 */
   1398         cfg.action_mask = BCM_FCMAP_ATTR_ALL_MASK;
   1399         cfg.action_mask2 |= BCM_FCMAP_ATTR2_ALL_MASK;
   1400         
   1401         cfg.port_mode = BCM_FCMAP_FCOE_TO_FC_MODE;
   1402         cfg.ingress_fc_crc_mode = 1;
   1403     }
   1404 
   1405     cfg.egress_fc_crc_mode = 1;
   1406     cfg.vlan_tag = 0x81006004;
   1407 #if FIP_VERSION_1
   1408     cfg.src_fcmap_prefix = 0x00fc00;
   1409     cfg.dst_fcmap_prefix = 0x00fc00;
   1410 #else
   1411     cfg.src_fcmap_prefix = 0x0efc00;
   1412     cfg.dst_fcmap_prefix = 0x0efc00;
   1413 #endif	
   1414    
   1415     ENET_SET_MACADDR(cfg.src_mac_addr, fcf_sa_mac);
   1416     cfg.src_mac_construct = BCM_FCMAP_ENCAP_FCOE_ETH_ADDRESS_USER;
   1417     cfg.dst_mac_construct = BCM_FCMAP_ENCAP_FCOE_FPMA;
   1418     if (bcm_fcmap_port_config_selective_set(unit, fc_port, &cfg) != BCM_E_NONE) {
   1419         cli_out("Port Configuration Set failed\n");
   1420         return BCM_E_FAIL;
   1421     }
   1422     
   1423     /* Initialize RX (FIP and FCoE packets rx)*/
   1424     cli_out("fcoe: Initializing RX ...");
   1425     if (fcoe_rx_init(unit) != BCM_E_NONE) {
   1426         /* goto clean_up; */
   1427         cli_out("fcoe: Failed \n");
   1428     } else {
   1429         cli_out("Done\n");
   1430     }
   1431 
   1432     cli_out("fcoe: FLogi to FC Switch ...");
   1433     /* Transmit FLOGI to FC switch */
   1434     if (fcoe_transmit_FLOGI(unit, fc_port) != BCM_E_NONE) {
   1435         cli_out("FLOGI to Switch failed \n");
   1436         return BCM_E_FAIL;
   1437     }
   1438     cli_out("Done\n");
   1439 
   1440     return BCM_E_NONE;
   1441 }
   1442 
   1443 int fcoe_pcs(int unit, int fc_port)
   1444 {
   1445     int rv;
   1446     bcm_fcmap_port_config_t cfg;
   1447 
   1448     memset(&cfg, 0, sizeof(cfg));
   1449     if ((rv = bcm_fcmap_port_config_get(unit, fc_port, &cfg)) != BCM_E_NONE) {
   1450         cli_out("Port Configuration retrive before apply failed\n");
   1451         return rv;
   1452     }
   1453 
   1454     /* Update config structure */
   1455     cfg.speed = BCM_FCMAP_PORT_SPEED_AN_2GBPS;
   1456 
   1457     if ((rv = bcm_fcmap_port_config_set(unit, fc_port, &cfg)) != BCM_E_NONE) {
   1458         cli_out("Port Configuration apply failed\n");
   1459         return rv;
   1460     }
   1461 
   1462     memset(&cfg, 0, sizeof(cfg));
   1463     if ((rv = bcm_fcmap_port_config_get(unit, fc_port, &cfg)) != BCM_E_NONE) {
   1464         cli_out("Port Configuration retrive after apply failed\n");
   1465         return rv;
   1466     }
   1467 
   1468     /* FC port Configurations */
   1469     _print_fcmap_cfg(&cfg);
   1470 
   1471 
   1472     return BCM_E_NONE;
   1473 }
   1474 
   1475 int fcoe_pcg(int unit, int fc_port)
   1476 {
   1477     int rv;
   1478     bcm_fcmap_port_config_t cfg;
   1479 
   1480 
   1481     /* Get FC port Configuration details */
   1482     memset(&cfg, 0, sizeof(cfg));
   1483     if ((rv = bcm_fcmap_port_config_get(unit, fc_port, &cfg)) != BCM_E_NONE) {
   1484         cli_out("Port Configuration retrive failed\n");
   1485         return rv;
   1486     }
   1487 
   1488     /* FC port Configurations */
   1489     _print_fcmap_cfg(&cfg);
   1490 
   1491 
   1492     return BCM_E_NONE;
   1493 }
   1494 
   1495 int fcoe_vms(int unit, int fc_port)
   1496 {
   1497     int rv;
   1498     int i = 0;
   1499     bcm_fcmap_vlan_vsan_map_t vlan[] = { { 0x101, 0x201 },
   1500                                          { 0x102, 0x202 },
   1501                                          { 0x103, 0x203 },
   1502                                          { 0x104, 0x204 },
   1503                                          { 0x105, 0x205 },
   1504                                          { 0x106, 0x206 },
   1505                                          { 0x107, 0x207 },
   1506                                          { 0x108, 0x208 },
   1507                                          { 0, 0 },
   1508                                        };
   1509 
   1510     while(vlan[i].vlan_vid) {
   1511         if ((rv = bcm_fcmap_vlan_map_add(unit, fc_port, &vlan[i])) != BCM_E_NONE) {
   1512             cli_out("Vlan Map Configuration failed\n");
   1513             return rv;
   1514         }
   1515         i++;
   1516     }
   1517 
   1518 
   1519     return BCM_E_NONE;
   1520 }
   1521 
   1522 int fcoe_vmg(int unit, int fc_port)
   1523 {
   1524     int rv;
   1525     int i = 0;
   1526     bcm_fcmap_vlan_vsan_map_t vlan = { 0xffff, 0xffff };
   1527 
   1528     while ((rv = bcm_fcmap_vlan_map_get(unit, fc_port, &vlan)) == BCM_E_NONE) {
   1529         cli_out("Vlan Map %u : vid=0x%x vfid=0x%x \n", 
   1530                 i++,  vlan.vlan_vid, vlan.vsan_vfid);
   1531     }
   1532 
   1533     if (rv == BFCMAP_E_UNAVAIL) {
   1534         return rv;
   1535     }
   1536 
   1537     return BCM_E_NONE;
   1538 }
   1539 
   1540 int fcoe_vmd(int unit, int fc_port)
   1541 {
   1542     int rv;
   1543     int i = 0;
   1544     bcm_fcmap_vlan_vsan_map_t vlan = { 0xffff, 0xffff };
   1545 
   1546     while ((rv = bcm_fcmap_vlan_map_get(unit, fc_port, &vlan)) == BCM_E_NONE) {
   1547         cli_out("Deleting Vlan Map %u : vid=0x%x vfid=0x%x \n", 
   1548                 i++,  vlan.vlan_vid, vlan.vsan_vfid);
   1549 
   1550         if (bcm_fcmap_vlan_map_delete(unit, fc_port, &vlan) != BCM_E_NONE) {
   1551             cli_out("Deleting Attempt Failed \n");
   1552             continue;
   1553         }
   1554     }
   1555 
   1556     if (rv == BFCMAP_E_UNAVAIL) {
   1557         return rv;
   1558     }
   1559 
   1560     return BCM_E_NONE;
   1561 }
   1562 
   1563 int fcoe_psc(int unit, int fc_port)
   1564 {
   1565     int rv;
   1566 
   1567     if ((rv = bcm_fcmap_stat_clear(unit, fc_port)) != BCM_E_NONE) {
   1568         cli_out("Stat clear failed \n");
   1569         return rv;
   1570     }
   1571 
   1572     return BCM_E_NONE;
   1573 }
   1574 
   1575 int fcoe_psg(int unit, int fc_port)
   1576 {
   1577     int rv;
   1578     int i = 0;
   1579     buint64_t  val;
   1580 
   1581     while ((rv = bcm_fcmap_stat_get(unit, fc_port, i,  &val)) == BCM_E_NONE) {
   1582         cli_out("Stat %03u : val = 0x%08x %08x\n",
   1583                 i++, COMPILER_64_HI(val), COMPILER_64_LO(val));
   1584     }
   1585 
   1586     if (rv == BFCMAP_E_UNAVAIL) {
   1587         return rv;
   1588     }
   1589 
   1590     return BCM_E_NONE;
   1591 }
   1592 
   1593 int fcoe_reset(int unit, int fc_port)
   1594 {
   1595     int rv;
   1596 
   1597     if ((rv = bcm_fcmap_port_link_reset(unit, fc_port)) != BCM_E_NONE) {
   1598         cli_out("Port reset failed \n");
   1599         return rv;
   1600     }
   1601 
   1602     return BCM_E_NONE;
   1603 }
   1604 
   1605 int fcoe_shutdown(int unit, int fc_port)
   1606 {
   1607     int rv;
   1608 
   1609     if ((rv = bcm_fcmap_port_shutdown(unit, fc_port)) != BCM_E_NONE) {
   1610         cli_out("Port shutdown failed \n");
   1611         return rv;
   1612     }
   1613 
   1614     return BCM_E_NONE;
   1615 }
   1616 
   1617 int fcoe_link_enable(int unit, int fc_port)
   1618 {
   1619     int rv;
   1620 
   1621     if ((rv = bcm_fcmap_port_enable(unit, fc_port)) != BCM_E_NONE) {
   1622         cli_out("Port link enable failed \n");
   1623         return rv;
   1624     }
   1625 
   1626     return BCM_E_NONE;
   1627 }
   1628 
   1629 /*
   1630  * Function: 	if_fcoe
   1631  * Purpose:	Start or stop fcoe NPV
   1632  * Parameters:	u - SOC unit #
   1633  *		a - pointer to args
   1634  * Returns:	CMD_OK/CMD_FAIL/
   1635  */
   1636 cmd_result_t
   1637 if_esw_fcoe(int u, args_t *a)
   1638 {
   1639     int rv;
   1640     soc_pbmp_t pbm ;
   1641     soc_port_t p, dport;
   1642     char *c;
   1643 
   1644     if (!sh_check_attached(ARG_CMD(a), u)) {
   1645         return CMD_FAIL;
   1646     }
   1647 
   1648     c = ARG_GET(a);
   1649     if (c != NULL && sal_strcasecmp(c, "start") == 0) {
   1650         if (((c = ARG_GET(a)) == NULL) || (parse_bcm_pbmp(u, c, &pbm) < 0)) {
   1651             cli_out("%s: ERROR: unrecognized port bitmap: %s\n", ARG_CMD(a), c);
   1652             return CMD_FAIL;
   1653         }
   1654 
   1655         if ((c = ARG_CUR(a)) != NULL) {
   1656             cli_out("Extra arguments ignored\n");
   1657         }
   1658         DPORT_SOC_PBMP_ITER(u, pbm, dport, p) {
   1659            if (fcoe_start(u, p) != BCM_E_NONE) {
   1660                cli_out("FCoE NPV start failed\n");
   1661                return CMD_FAIL;
   1662            } else {
   1663                cli_out("FCoE NPV Started\n");
   1664            }
   1665         }
   1666         return CMD_OK;
   1667     }
   1668 
   1669     if (c != NULL && sal_strcasecmp(c, "stop") == 0) {
   1670         /* fcoe_stop(unit) */
   1671     }
   1672 
   1673 #define  FCOE_PORT_FUNCION_INVOKE( _cmd, _func )\
   1674         if (sal_strcasecmp(c, _cmd ) == 0) {                        \
   1675             DPORT_SOC_PBMP_ITER(u, pbm, dport, p) {                 \
   1676                 if ((rv = _func(u, p)) != BCM_E_NONE) {             \
   1677                     if (rv == BCM_E_UNAVAIL) {                      \
   1678                         cli_out("No FCOE warmboot recovery done."    \
   1679                            " Please run: warmboot command first\n");\
   1680                     } else {                                        \
   1681                         cli_out("FCoE " _cmd " failed\n");           \
   1682                     }                                               \
   1683                     return CMD_FAIL;                                \
   1684                 } else {                                            \
   1685                     cli_out("FCoE " _cmd " done\n");                 \
   1686                 }                                                   \
   1687             }                                                       \
   1688         }
   1689 
   1690     if (c != NULL && sal_strcasecmp(c, "port") == 0) {
   1691         if (((c = ARG_GET(a)) == NULL) || (parse_bcm_pbmp(u, c, &pbm) < 0)) {
   1692             cli_out("%s: ERROR: unrecognized port bitmap: %s\n", ARG_CMD(a), c);
   1693             return CMD_FAIL;
   1694         }
   1695 
   1696         if ((c = ARG_GET(a)) == NULL) {
   1697             cli_out("Action requested is missing\n");
   1698             return CMD_FAIL;
   1699         }
   1700 
   1701         FCOE_PORT_FUNCION_INVOKE( "cset" , fcoe_pcs );
   1702         FCOE_PORT_FUNCION_INVOKE( "cget" , fcoe_pcg );
   1703         FCOE_PORT_FUNCION_INVOKE( "vmset" , fcoe_vms );
   1704         FCOE_PORT_FUNCION_INVOKE( "vmget" , fcoe_vmg );
   1705         FCOE_PORT_FUNCION_INVOKE( "vmdel" , fcoe_vmd );
   1706         FCOE_PORT_FUNCION_INVOKE( "statc" , fcoe_psc );
   1707         FCOE_PORT_FUNCION_INVOKE( "statg" , fcoe_psg );
   1708         FCOE_PORT_FUNCION_INVOKE( "reset" , fcoe_reset );
   1709         FCOE_PORT_FUNCION_INVOKE( "shutdown" , fcoe_shutdown );
   1710         FCOE_PORT_FUNCION_INVOKE( "enable" , fcoe_link_enable );
   1711 
   1712         return CMD_OK;
   1713     }
   1714 #ifdef BCM_WARM_BOOT_SUPPORT
   1715     if (c != NULL && sal_strcasecmp(c, "warmboot") == 0) {
   1716         bfcmap_warmboot_recover();
   1717         return CMD_OK;
   1718     }
   1719 #endif
   1720     return CMD_OK;
   1721 }
   1722 
   1723 #endif /*INCLUDE_FCMAP */