Print this page
9724 qede needs updates for newer GCC


  16 * fields enclosed by brackets "[]" replaced with your own identifying
  17 * information: Portions Copyright [yyyy] [name of copyright owner]
  18 *
  19 * CDDL HEADER END
  20 */
  21 
  22 /*
  23 * Copyright 2014-2017 Cavium, Inc. 
  24 * The contents of this file are subject to the terms of the Common Development 
  25 * and Distribution License, v.1,  (the "License").
  26 
  27 * You may not use this file except in compliance with the License.
  28 
  29 * You can obtain a copy of the License at available 
  30 * at http://opensource.org/licenses/CDDL-1.0
  31 
  32 * See the License for the specific language governing permissions and 
  33 * limitations under the License.
  34 */
  35 



  36 
  37 #include "qede.h"
  38 
  39 #define FP_LOCK(ptr)    \
  40 mutex_enter(&ptr->fp_lock);
  41 #define FP_UNLOCK(ptr)  \
  42 mutex_exit(&ptr->fp_lock);
  43 
  44 int
  45 qede_ucst_find(qede_t *qede, const uint8_t *mac_addr)
  46 {
  47         int slot;
  48 
  49         for(slot = 0; slot < qede->ucst_total; slot++) {
  50                 if (bcmp(qede->ucst_mac[slot].mac_addr.ether_addr_octet,
  51                     mac_addr, ETHERADDRL) == 0) {
  52                         return (slot);
  53                 }
  54         }
  55         return (-1);


1246     mblk = qede_ring_tx((void *)fp, mblk);
1247 
1248     return (mblk);
1249 }
1250 #endif  /* NO_CROSSBOW */
1251 
1252 
1253 static lb_property_t loopmodes[] = {
1254         { normal,       "normal",       QEDE_LOOP_NONE                },
1255         { internal,     "internal",     QEDE_LOOP_INTERNAL            },
1256         { external,     "external",     QEDE_LOOP_EXTERNAL            },
1257 };
1258 
1259 /* 
1260  * Set Loopback mode 
1261  */
1262 
1263 static enum ioc_reply
1264 qede_set_loopback_mode(qede_t *qede, uint32_t mode)
1265 {
1266         int ret, i = 0;
1267         struct ecore_dev *edev = &qede->edev;
1268         struct ecore_hwfn *hwfn;
1269         struct ecore_ptt *ptt = NULL;
1270         struct ecore_mcp_link_params *link_params;
1271 
1272         hwfn = &edev->hwfns[0];
1273         link_params = ecore_mcp_get_link_params(hwfn);
1274         ptt = ecore_ptt_acquire(hwfn);
1275 
1276         switch(mode) {
1277         default:
1278                 qede_info(qede, "unknown loopback mode !!");
1279                 ecore_ptt_release(hwfn, ptt);
1280                 return IOC_INVAL;
1281 
1282         case QEDE_LOOP_NONE:
1283                 ecore_mcp_set_link(hwfn, ptt, 0);
1284 
1285                 while (qede->params.link_state && i < 5000) {
1286                         OSAL_MSLEEP(1);
1287                         i++;
1288                 }
1289                 i = 0;
1290 
1291                 link_params->loopback_mode = ETH_LOOPBACK_NONE;
1292                 qede->loop_back_mode = QEDE_LOOP_NONE;
1293                 ret = ecore_mcp_set_link(hwfn, ptt, 1);
1294                 ecore_ptt_release(hwfn, ptt);
1295 
1296                 while (!qede->params.link_state && i < 5000) {
1297                         OSAL_MSLEEP(1);
1298                         i++;
1299                 }
1300                 return IOC_REPLY;
1301 
1302         case QEDE_LOOP_INTERNAL:
1303                 qede_print("!%s(%d) : loopback mode (INTERNAL) is set!",
1304                     __func__, qede->instance);
1305                     ecore_mcp_set_link(hwfn, ptt, 0);
1306 
1307                 while(qede->params.link_state && i < 5000) {
1308                         OSAL_MSLEEP(1);
1309                         i++;
1310                 }
1311                 i = 0;
1312                 link_params->loopback_mode = ETH_LOOPBACK_INT_PHY;
1313                 qede->loop_back_mode = QEDE_LOOP_INTERNAL;
1314                 ret = ecore_mcp_set_link(hwfn, ptt, 1);
1315                 ecore_ptt_release(hwfn, ptt);
1316 
1317                 while(!qede->params.link_state && i < 5000) {
1318                         OSAL_MSLEEP(1);
1319                         i++;
1320                 }
1321                 return IOC_REPLY;
1322 
1323         case QEDE_LOOP_EXTERNAL:
1324                 qede_print("!%s(%d) : External loopback mode is not supported",
1325                     __func__, qede->instance);
1326                 ecore_ptt_release(hwfn, ptt);
1327                 return IOC_INVAL;
1328         }
1329 }
1330 
1331 static int
1332 qede_ioctl_pcicfg_rd(qede_t *qede, u32 addr, void *data,
1333     int len)
1334 {


1447                 break;
1448                 
1449         case QEDE_REG_WRITE:
1450                 ecore_wr(p_hwfn, p_hwfn->p_main_ptt, addr, val);
1451                 break;
1452 
1453         default:
1454                 cmn_err(CE_WARN, 
1455                     "wrong command in register read/write from application\n");
1456                 break;
1457         }
1458         return (ret);
1459 }
1460 
1461 static int
1462 qede_ioctl_rd_wr_nvram(qede_t *qede, mblk_t *mp)
1463 {
1464         qede_nvram_data_t *data1 = (qede_nvram_data_t *)(mp->b_cont->b_rptr); 
1465         qede_nvram_data_t *data2, *next_data;
1466         struct ecore_dev *edev = &qede->edev;
1467         uint32_t ret = 0, hdr_size = 24, bytes_to_copy, copy_len = 0;
1468         uint32_t copy_len1 = 0;
1469         uint32_t addr = data1->off;
1470         uint32_t size = data1->size, i, buf_size;
1471         uint8_t cmd, cmd2;
1472         uint8_t *buf, *tmp_buf;
1473         mblk_t *mp1;
1474 
1475         cmd = (uint8_t)data1->unused1;
1476 
1477         switch(cmd) {
1478         case QEDE_NVRAM_CMD_READ:
1479                 buf = kmem_zalloc(size, GFP_KERNEL);
1480                 if(buf == NULL) {
1481                         cmn_err(CE_WARN, "memory allocation failed" 
1482                         " in nvram read ioctl\n");
1483                         return (DDI_FAILURE);
1484                 }
1485                 ret = ecore_mcp_nvm_read(edev, addr, buf, data1->size);
1486 
1487                 copy_len = (MBLKL(mp->b_cont)) - hdr_size;
1488                 if(copy_len > size) {
1489                         (void) memcpy(data1->uabc, buf, size);
1490                         kmem_free(buf, size);
1491                         //OSAL_FREE(edev, buf);
1492                         ret = 0;
1493                         break;
1494                 }
1495                 (void) memcpy(data1->uabc, buf, copy_len);
1496                 bytes_to_copy = size - copy_len;
1497                 tmp_buf = ((uint8_t *)buf) + copy_len;
1498                 copy_len1 = copy_len;
1499                 mp1 = mp->b_cont;
1500                 mp1 = mp1->b_cont;
1501 
1502                 while (mp1) {
1503                         copy_len = MBLKL(mp1);
1504                         if(mp1->b_cont == NULL) {
1505                                 copy_len = MBLKL(mp1) - 4;
1506                         }
1507                         data2 = (qede_nvram_data_t *)mp1->b_rptr;
1508                         if (copy_len > bytes_to_copy) {
1509                                 (void) memcpy(data2->uabc, tmp_buf, 
1510                                     bytes_to_copy);
1511                                 kmem_free(buf, size);
1512                                 //OSAL_FREE(edev, buf);
1513                                 break;
1514                         }
1515                         (void) memcpy(data2->uabc, tmp_buf, copy_len);
1516                         tmp_buf = tmp_buf + copy_len;
1517                         copy_len += copy_len;
1518                         mp1 = mp1->b_cont;
1519                         bytes_to_copy = bytes_to_copy - copy_len;
1520                 }
1521                         
1522                 kmem_free(buf, size);
1523                 //OSAL_FREE(edev, buf);
1524                 break;
1525         
1526         case QEDE_NVRAM_CMD_WRITE:
1527                 cmd2 = (uint8_t )data1->cmd2;
1528                 size = data1->size;
1529                 addr = data1->off;
1530                 buf_size =  size; //data1->buf_size;
1531                 //buf_size =  data1->buf_size;
1532                 ret = 0;
1533 
1534                 switch(cmd2){
1535                 case START_NVM_WRITE:
1536                         buf = kmem_zalloc(size, GFP_KERNEL);
1537                         //buf = qede->reserved_buf;
1538                         qede->nvm_buf_size = data1->size;
1539                         if(buf == NULL) {
1540                                 cmn_err(CE_WARN, 
1541                                 "memory allocation failed in START_NVM_WRITE\n");
1542                                 return DDI_FAILURE;
1543                         }
1544                         qede->nvm_buf_start = buf;
1545                         cmn_err(CE_NOTE, 
1546                             "buf = %p, size = %x\n", qede->nvm_buf_start, size);
1547                         qede->nvm_buf = buf;
1548                         qede->copy_len = 0;
1549                         //tmp_buf = buf + addr;
1550                         ret = 0;
1551                         break;
1552                         
1553                 case ACCUMULATE_NVM_BUF:
1554                         tmp_buf = qede->nvm_buf;
1555                         copy_len = MBLKL(mp->b_cont) - hdr_size;
1556                         if(copy_len > buf_size) {
1557                                 if (buf_size < qede->nvm_buf_size) {
1558                                 (void) memcpy(tmp_buf, data1->uabc, buf_size);
1559                                         qede->copy_len = qede->copy_len + 
1560                                             buf_size;
1561                                 } else {
1562                                         (void) memcpy(tmp_buf, 
1563                                             data1->uabc, qede->nvm_buf_size);
1564                                         qede->copy_len = 
1565                                             qede->copy_len + qede->nvm_buf_size;
1566                                 }
1567                                 tmp_buf = tmp_buf + buf_size;
1568                                 qede->nvm_buf = tmp_buf;
1569                                 //qede->copy_len = qede->copy_len + buf_size;
1570                                 cmn_err(CE_NOTE, 
1571                                     "buf_size from app = %x\n", copy_len);
1572                                 ret = 0;
1573                                 break;
1574                         }
1575                         (void) memcpy(tmp_buf, data1->uabc, copy_len);
1576                         tmp_buf = tmp_buf + copy_len;
1577                         bytes_to_copy = buf_size - copy_len;
1578                         mp1 = mp->b_cont;
1579                         mp1 = mp1->b_cont;
1580                         copy_len1 = copy_len;
1581                         
1582                         while (mp1) {
1583                                 copy_len = MBLKL(mp1);
1584                                 if (mp1->b_cont == NULL) {
1585                                         copy_len = MBLKL(mp1) - 4;
1586                                 }
1587                                 next_data = (qede_nvram_data_t *) mp1->b_rptr;
1588                                 if (copy_len > bytes_to_copy){
1589                                         (void) memcpy(tmp_buf, next_data->uabc,
1590                                             bytes_to_copy);
1591                                         qede->copy_len = qede->copy_len + 
1592                                             bytes_to_copy;
1593                                         ret = 0;
1594                                         break;
1595                                 }
1596                                 (void) memcpy(tmp_buf, next_data->uabc, 
1597                                     copy_len);
1598                                 qede->copy_len = qede->copy_len + copy_len;
1599                                 tmp_buf = tmp_buf + copy_len;
1600                                 copy_len = copy_len1 + copy_len;
1601                                 bytes_to_copy = bytes_to_copy - copy_len;
1602                                 mp1 = mp1->b_cont;
1603                         }
1604                         qede->nvm_buf = tmp_buf;
1605                         ret = 0;
1606                         break;
1607 
1608                 case STOP_NVM_WRITE:
1609                         //qede->nvm_buf = tmp_buf;
1610                         ret = 0;
1611                         break;
1612                 case READ_BUF:
1613                         tmp_buf = (uint8_t *)qede->nvm_buf_start;
1614                         for(i = 0; i < size ; i++){
1615                                 cmn_err(CE_NOTE, 
1616                                     "buff (%d) : %d\n", i, *tmp_buf);
1617                                 tmp_buf ++;
1618                         }
1619                         ret = 0;
1620                         break;
1621                 }
1622                 break;
1623         case QEDE_NVRAM_CMD_PUT_FILE_DATA:
1624                 tmp_buf = qede->nvm_buf_start;       
1625                 ret = ecore_mcp_nvm_write(edev, ECORE_PUT_FILE_DATA,
1626                           addr, tmp_buf, size);
1627                 kmem_free(qede->nvm_buf_start, size);
1628                 //OSAL_FREE(edev, tmp_buf);
1629                 cmn_err(CE_NOTE, "total size = %x, copied size = %x\n",
1630                     qede->nvm_buf_size, qede->copy_len);
1631                 tmp_buf = NULL;
1632                 qede->nvm_buf = NULL;
1633                 qede->nvm_buf_start = NULL;
1634                 ret = 0;
1635                 break;
1636 
1637         case QEDE_NVRAM_CMD_SET_SECURE_MODE:
1638                 ret = ecore_mcp_nvm_set_secure_mode(edev, addr);
1639                 break;
1640 
1641         case QEDE_NVRAM_CMD_DEL_FILE:
1642                 ret = ecore_mcp_nvm_del_file(edev, addr);
1643                 break;
1644 
1645         case QEDE_NVRAM_CMD_PUT_FILE_BEGIN:
1646                 ret = ecore_mcp_nvm_put_file_begin(edev, addr);
1647                 break;
1648 
1649         case QEDE_NVRAM_CMD_GET_NVRAM_RESP:
1650                 buf = kmem_zalloc(size, KM_SLEEP);
1651                 ret = ecore_mcp_nvm_resp(edev, buf);
1652                 (void)memcpy(data1->uabc, buf, size);
1653                 kmem_free(buf, size);
1654                 break;
1655 
1656         default:
1657                 cmn_err(CE_WARN, 
1658                     "wrong command in NVRAM read/write from application\n");
1659                 break;
1660         }
1661         return (DDI_SUCCESS);   
1662 }
1663 
1664 static int
1665 qede_get_func_info(qede_t *qede, void *data)
1666 {
1667         qede_link_output_t link_op;
1668         qede_func_info_t func_info;
1669         qede_ioctl_data_t *data1 = (qede_ioctl_data_t *)data;
1670         struct ecore_dev *edev = &qede->edev;
1671         struct ecore_hwfn *hwfn;




  16 * fields enclosed by brackets "[]" replaced with your own identifying
  17 * information: Portions Copyright [yyyy] [name of copyright owner]
  18 *
  19 * CDDL HEADER END
  20 */
  21 
  22 /*
  23 * Copyright 2014-2017 Cavium, Inc. 
  24 * The contents of this file are subject to the terms of the Common Development 
  25 * and Distribution License, v.1,  (the "License").
  26 
  27 * You may not use this file except in compliance with the License.
  28 
  29 * You can obtain a copy of the License at available 
  30 * at http://opensource.org/licenses/CDDL-1.0
  31 
  32 * See the License for the specific language governing permissions and 
  33 * limitations under the License.
  34 */
  35 
  36 /*
  37  * Copyright 2018 Joyent, Inc.
  38  */
  39 
  40 #include "qede.h"
  41 
  42 #define FP_LOCK(ptr)    \
  43 mutex_enter(&ptr->fp_lock);
  44 #define FP_UNLOCK(ptr)  \
  45 mutex_exit(&ptr->fp_lock);
  46 
  47 int
  48 qede_ucst_find(qede_t *qede, const uint8_t *mac_addr)
  49 {
  50         int slot;
  51 
  52         for(slot = 0; slot < qede->ucst_total; slot++) {
  53                 if (bcmp(qede->ucst_mac[slot].mac_addr.ether_addr_octet,
  54                     mac_addr, ETHERADDRL) == 0) {
  55                         return (slot);
  56                 }
  57         }
  58         return (-1);


1249     mblk = qede_ring_tx((void *)fp, mblk);
1250 
1251     return (mblk);
1252 }
1253 #endif  /* NO_CROSSBOW */
1254 
1255 
1256 static lb_property_t loopmodes[] = {
1257         { normal,       "normal",       QEDE_LOOP_NONE                },
1258         { internal,     "internal",     QEDE_LOOP_INTERNAL            },
1259         { external,     "external",     QEDE_LOOP_EXTERNAL            },
1260 };
1261 
1262 /* 
1263  * Set Loopback mode 
1264  */
1265 
1266 static enum ioc_reply
1267 qede_set_loopback_mode(qede_t *qede, uint32_t mode)
1268 {
1269         int i = 0;
1270         struct ecore_dev *edev = &qede->edev;
1271         struct ecore_hwfn *hwfn;
1272         struct ecore_ptt *ptt = NULL;
1273         struct ecore_mcp_link_params *link_params;
1274 
1275         hwfn = &edev->hwfns[0];
1276         link_params = ecore_mcp_get_link_params(hwfn);
1277         ptt = ecore_ptt_acquire(hwfn);
1278 
1279         switch(mode) {
1280         default:
1281                 qede_info(qede, "unknown loopback mode !!");
1282                 ecore_ptt_release(hwfn, ptt);
1283                 return IOC_INVAL;
1284 
1285         case QEDE_LOOP_NONE:
1286                 ecore_mcp_set_link(hwfn, ptt, 0);
1287 
1288                 while (qede->params.link_state && i < 5000) {
1289                         OSAL_MSLEEP(1);
1290                         i++;
1291                 }
1292                 i = 0;
1293 
1294                 link_params->loopback_mode = ETH_LOOPBACK_NONE;
1295                 qede->loop_back_mode = QEDE_LOOP_NONE;
1296                 (void) ecore_mcp_set_link(hwfn, ptt, 1);
1297                 ecore_ptt_release(hwfn, ptt);
1298 
1299                 while (!qede->params.link_state && i < 5000) {
1300                         OSAL_MSLEEP(1);
1301                         i++;
1302                 }
1303                 return IOC_REPLY;
1304 
1305         case QEDE_LOOP_INTERNAL:
1306                 qede_print("!%s(%d) : loopback mode (INTERNAL) is set!",
1307                     __func__, qede->instance);
1308                     ecore_mcp_set_link(hwfn, ptt, 0);
1309 
1310                 while(qede->params.link_state && i < 5000) {
1311                         OSAL_MSLEEP(1);
1312                         i++;
1313                 }
1314                 i = 0;
1315                 link_params->loopback_mode = ETH_LOOPBACK_INT_PHY;
1316                 qede->loop_back_mode = QEDE_LOOP_INTERNAL;
1317                 (void) ecore_mcp_set_link(hwfn, ptt, 1);
1318                 ecore_ptt_release(hwfn, ptt);
1319 
1320                 while(!qede->params.link_state && i < 5000) {
1321                         OSAL_MSLEEP(1);
1322                         i++;
1323                 }
1324                 return IOC_REPLY;
1325 
1326         case QEDE_LOOP_EXTERNAL:
1327                 qede_print("!%s(%d) : External loopback mode is not supported",
1328                     __func__, qede->instance);
1329                 ecore_ptt_release(hwfn, ptt);
1330                 return IOC_INVAL;
1331         }
1332 }
1333 
1334 static int
1335 qede_ioctl_pcicfg_rd(qede_t *qede, u32 addr, void *data,
1336     int len)
1337 {


1450                 break;
1451                 
1452         case QEDE_REG_WRITE:
1453                 ecore_wr(p_hwfn, p_hwfn->p_main_ptt, addr, val);
1454                 break;
1455 
1456         default:
1457                 cmn_err(CE_WARN, 
1458                     "wrong command in register read/write from application\n");
1459                 break;
1460         }
1461         return (ret);
1462 }
1463 
1464 static int
1465 qede_ioctl_rd_wr_nvram(qede_t *qede, mblk_t *mp)
1466 {
1467         qede_nvram_data_t *data1 = (qede_nvram_data_t *)(mp->b_cont->b_rptr); 
1468         qede_nvram_data_t *data2, *next_data;
1469         struct ecore_dev *edev = &qede->edev;
1470         uint32_t hdr_size = 24, bytes_to_copy, copy_len = 0;
1471         uint32_t copy_len1 = 0;
1472         uint32_t addr = data1->off;
1473         uint32_t size = data1->size, i, buf_size;
1474         uint8_t cmd, cmd2;
1475         uint8_t *buf, *tmp_buf;
1476         mblk_t *mp1;
1477 
1478         cmd = (uint8_t)data1->unused1;
1479 
1480         switch(cmd) {
1481         case QEDE_NVRAM_CMD_READ:
1482                 buf = kmem_zalloc(size, GFP_KERNEL);
1483                 if(buf == NULL) {
1484                         cmn_err(CE_WARN, "memory allocation failed" 
1485                         " in nvram read ioctl\n");
1486                         return (DDI_FAILURE);
1487                 }
1488                 (void) ecore_mcp_nvm_read(edev, addr, buf, data1->size);
1489 
1490                 copy_len = (MBLKL(mp->b_cont)) - hdr_size;
1491                 if(copy_len > size) {
1492                         (void) memcpy(data1->uabc, buf, size);
1493                         kmem_free(buf, size);
1494                         //OSAL_FREE(edev, buf);

1495                         break;
1496                 }
1497                 (void) memcpy(data1->uabc, buf, copy_len);
1498                 bytes_to_copy = size - copy_len;
1499                 tmp_buf = ((uint8_t *)buf) + copy_len;
1500                 copy_len1 = copy_len;
1501                 mp1 = mp->b_cont;
1502                 mp1 = mp1->b_cont;
1503 
1504                 while (mp1) {
1505                         copy_len = MBLKL(mp1);
1506                         if(mp1->b_cont == NULL) {
1507                                 copy_len = MBLKL(mp1) - 4;
1508                         }
1509                         data2 = (qede_nvram_data_t *)mp1->b_rptr;
1510                         if (copy_len > bytes_to_copy) {
1511                                 (void) memcpy(data2->uabc, tmp_buf, 
1512                                     bytes_to_copy);
1513                                 kmem_free(buf, size);
1514                                 //OSAL_FREE(edev, buf);
1515                                 break;
1516                         }
1517                         (void) memcpy(data2->uabc, tmp_buf, copy_len);
1518                         tmp_buf = tmp_buf + copy_len;
1519                         copy_len += copy_len;
1520                         mp1 = mp1->b_cont;
1521                         bytes_to_copy = bytes_to_copy - copy_len;
1522                 }
1523                         
1524                 kmem_free(buf, size);
1525                 //OSAL_FREE(edev, buf);
1526                 break;
1527         
1528         case QEDE_NVRAM_CMD_WRITE:
1529                 cmd2 = (uint8_t )data1->cmd2;
1530                 size = data1->size;
1531                 addr = data1->off;
1532                 buf_size =  size; //data1->buf_size;
1533                 //buf_size =  data1->buf_size;

1534 
1535                 switch(cmd2){
1536                 case START_NVM_WRITE:
1537                         buf = kmem_zalloc(size, GFP_KERNEL);
1538                         //buf = qede->reserved_buf;
1539                         qede->nvm_buf_size = data1->size;
1540                         if(buf == NULL) {
1541                                 cmn_err(CE_WARN, 
1542                                 "memory allocation failed in START_NVM_WRITE\n");
1543                                 return DDI_FAILURE;
1544                         }
1545                         qede->nvm_buf_start = buf;
1546                         cmn_err(CE_NOTE, 
1547                             "buf = %p, size = %x\n", qede->nvm_buf_start, size);
1548                         qede->nvm_buf = buf;
1549                         qede->copy_len = 0;
1550                         //tmp_buf = buf + addr;

1551                         break;
1552                         
1553                 case ACCUMULATE_NVM_BUF:
1554                         tmp_buf = qede->nvm_buf;
1555                         copy_len = MBLKL(mp->b_cont) - hdr_size;
1556                         if(copy_len > buf_size) {
1557                                 if (buf_size < qede->nvm_buf_size) {
1558                                 (void) memcpy(tmp_buf, data1->uabc, buf_size);
1559                                         qede->copy_len = qede->copy_len + 
1560                                             buf_size;
1561                                 } else {
1562                                         (void) memcpy(tmp_buf, 
1563                                             data1->uabc, qede->nvm_buf_size);
1564                                         qede->copy_len = 
1565                                             qede->copy_len + qede->nvm_buf_size;
1566                                 }
1567                                 tmp_buf = tmp_buf + buf_size;
1568                                 qede->nvm_buf = tmp_buf;
1569                                 //qede->copy_len = qede->copy_len + buf_size;
1570                                 cmn_err(CE_NOTE, 
1571                                     "buf_size from app = %x\n", copy_len);

1572                                 break;
1573                         }
1574                         (void) memcpy(tmp_buf, data1->uabc, copy_len);
1575                         tmp_buf = tmp_buf + copy_len;
1576                         bytes_to_copy = buf_size - copy_len;
1577                         mp1 = mp->b_cont;
1578                         mp1 = mp1->b_cont;
1579                         copy_len1 = copy_len;
1580                         
1581                         while (mp1) {
1582                                 copy_len = MBLKL(mp1);
1583                                 if (mp1->b_cont == NULL) {
1584                                         copy_len = MBLKL(mp1) - 4;
1585                                 }
1586                                 next_data = (qede_nvram_data_t *) mp1->b_rptr;
1587                                 if (copy_len > bytes_to_copy){
1588                                         (void) memcpy(tmp_buf, next_data->uabc,
1589                                             bytes_to_copy);
1590                                         qede->copy_len = qede->copy_len + 
1591                                             bytes_to_copy;

1592                                         break;
1593                                 }
1594                                 (void) memcpy(tmp_buf, next_data->uabc, 
1595                                     copy_len);
1596                                 qede->copy_len = qede->copy_len + copy_len;
1597                                 tmp_buf = tmp_buf + copy_len;
1598                                 copy_len = copy_len1 + copy_len;
1599                                 bytes_to_copy = bytes_to_copy - copy_len;
1600                                 mp1 = mp1->b_cont;
1601                         }
1602                         qede->nvm_buf = tmp_buf;

1603                         break;
1604 
1605                 case STOP_NVM_WRITE:
1606                         //qede->nvm_buf = tmp_buf;

1607                         break;
1608                 case READ_BUF:
1609                         tmp_buf = (uint8_t *)qede->nvm_buf_start;
1610                         for(i = 0; i < size ; i++){
1611                                 cmn_err(CE_NOTE, 
1612                                     "buff (%d) : %d\n", i, *tmp_buf);
1613                                 tmp_buf ++;
1614                         }

1615                         break;
1616                 }
1617                 break;
1618         case QEDE_NVRAM_CMD_PUT_FILE_DATA:
1619                 tmp_buf = qede->nvm_buf_start;       
1620                 (void) ecore_mcp_nvm_write(edev, ECORE_PUT_FILE_DATA,
1621                           addr, tmp_buf, size);
1622                 kmem_free(qede->nvm_buf_start, size);
1623                 //OSAL_FREE(edev, tmp_buf);
1624                 cmn_err(CE_NOTE, "total size = %x, copied size = %x\n",
1625                     qede->nvm_buf_size, qede->copy_len);
1626                 tmp_buf = NULL;
1627                 qede->nvm_buf = NULL;
1628                 qede->nvm_buf_start = NULL;

1629                 break;
1630 
1631         case QEDE_NVRAM_CMD_SET_SECURE_MODE:
1632                 (void) ecore_mcp_nvm_set_secure_mode(edev, addr);
1633                 break;
1634 
1635         case QEDE_NVRAM_CMD_DEL_FILE:
1636                 (void) ecore_mcp_nvm_del_file(edev, addr);
1637                 break;
1638 
1639         case QEDE_NVRAM_CMD_PUT_FILE_BEGIN:
1640                 (void) ecore_mcp_nvm_put_file_begin(edev, addr);
1641                 break;
1642 
1643         case QEDE_NVRAM_CMD_GET_NVRAM_RESP:
1644                 buf = kmem_zalloc(size, KM_SLEEP);
1645                 (void) ecore_mcp_nvm_resp(edev, buf);
1646                 (void)memcpy(data1->uabc, buf, size);
1647                 kmem_free(buf, size);
1648                 break;
1649 
1650         default:
1651                 cmn_err(CE_WARN, 
1652                     "wrong command in NVRAM read/write from application\n");
1653                 break;
1654         }
1655         return (DDI_SUCCESS);   
1656 }
1657 
1658 static int
1659 qede_get_func_info(qede_t *qede, void *data)
1660 {
1661         qede_link_output_t link_op;
1662         qede_func_info_t func_info;
1663         qede_ioctl_data_t *data1 = (qede_ioctl_data_t *)data;
1664         struct ecore_dev *edev = &qede->edev;
1665         struct ecore_hwfn *hwfn;