lpfc_scsi.c (02e2407858fd62053bf60349c0e72cd1c7a4a60e) | lpfc_scsi.c (7f86059ac016d8662e5fbfab4875529510977b47) |
---|---|
1/******************************************************************* 2 * This file is part of the Emulex Linux Device Driver for * 3 * Fibre Channel Host Bus Adapters. * 4 * Copyright (C) 2004-2009 Emulex. All rights reserved. * 5 * EMULEX and SLI are trademarks of Emulex. * 6 * www.emulex.com * 7 * Portions Copyright (C) 2004-2005 Christoph Hellwig * 8 * * --- 1500 unchanged lines hidden (view full) --- 1509static int 1510lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc, 1511 struct ulp_bde64 *bpl, int datacnt, int protcnt) 1512{ 1513 struct scatterlist *sgde = NULL; /* s/g data entry */ 1514 struct scatterlist *sgpe = NULL; /* s/g prot entry */ 1515 struct lpfc_pde5 *pde5 = NULL; 1516 struct lpfc_pde6 *pde6 = NULL; | 1/******************************************************************* 2 * This file is part of the Emulex Linux Device Driver for * 3 * Fibre Channel Host Bus Adapters. * 4 * Copyright (C) 2004-2009 Emulex. All rights reserved. * 5 * EMULEX and SLI are trademarks of Emulex. * 6 * www.emulex.com * 7 * Portions Copyright (C) 2004-2005 Christoph Hellwig * 8 * * --- 1500 unchanged lines hidden (view full) --- 1509static int 1510lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc, 1511 struct ulp_bde64 *bpl, int datacnt, int protcnt) 1512{ 1513 struct scatterlist *sgde = NULL; /* s/g data entry */ 1514 struct scatterlist *sgpe = NULL; /* s/g prot entry */ 1515 struct lpfc_pde5 *pde5 = NULL; 1516 struct lpfc_pde6 *pde6 = NULL; |
1517 struct ulp_bde64 *prot_bde = NULL; | 1517 struct lpfc_pde7 *pde7 = NULL; |
1518 dma_addr_t dataphysaddr, protphysaddr; 1519 unsigned short curr_data = 0, curr_prot = 0; | 1518 dma_addr_t dataphysaddr, protphysaddr; 1519 unsigned short curr_data = 0, curr_prot = 0; |
1520 unsigned int split_offset, protgroup_len; | 1520 unsigned int split_offset; 1521 unsigned int protgroup_len, protgroup_offset = 0, protgroup_remainder; |
1521 unsigned int protgrp_blks, protgrp_bytes; 1522 unsigned int remainder, subtotal; 1523 int status; 1524 int datadir = sc->sc_data_direction; 1525 unsigned char pgdone = 0, alldone = 0; 1526 unsigned blksize; 1527 uint32_t reftag; 1528 uint16_t apptagmask, apptagval; --- 51 unchanged lines hidden (view full) --- 1580 pde6->word1 = cpu_to_le32(pde6->word1); 1581 pde6->word2 = cpu_to_le32(pde6->word2); 1582 1583 /* advance bpl and increment bde count */ 1584 num_bde++; 1585 bpl++; 1586 1587 /* setup the first BDE that points to protection buffer */ | 1522 unsigned int protgrp_blks, protgrp_bytes; 1523 unsigned int remainder, subtotal; 1524 int status; 1525 int datadir = sc->sc_data_direction; 1526 unsigned char pgdone = 0, alldone = 0; 1527 unsigned blksize; 1528 uint32_t reftag; 1529 uint16_t apptagmask, apptagval; --- 51 unchanged lines hidden (view full) --- 1581 pde6->word1 = cpu_to_le32(pde6->word1); 1582 pde6->word2 = cpu_to_le32(pde6->word2); 1583 1584 /* advance bpl and increment bde count */ 1585 num_bde++; 1586 bpl++; 1587 1588 /* setup the first BDE that points to protection buffer */ |
1588 prot_bde = (struct ulp_bde64 *) bpl; 1589 protphysaddr = sg_dma_address(sgpe); 1590 prot_bde->addrHigh = le32_to_cpu(putPaddrLow(protphysaddr)); 1591 prot_bde->addrLow = le32_to_cpu(putPaddrHigh(protphysaddr)); 1592 protgroup_len = sg_dma_len(sgpe); | 1589 protphysaddr = sg_dma_address(sgpe) + protgroup_offset; 1590 protgroup_len = sg_dma_len(sgpe) - protgroup_offset; |
1593 1594 /* must be integer multiple of the DIF block length */ 1595 BUG_ON(protgroup_len % 8); 1596 | 1591 1592 /* must be integer multiple of the DIF block length */ 1593 BUG_ON(protgroup_len % 8); 1594 |
1595 pde7 = (struct lpfc_pde7 *) bpl; 1596 memset(pde7, 0, sizeof(struct lpfc_pde7)); 1597 bf_set(pde7_type, pde7, LPFC_PDE7_DESCRIPTOR); 1598 1599 pde7->addrHigh = le32_to_cpu(putPaddrLow(protphysaddr)); 1600 pde7->addrLow = le32_to_cpu(putPaddrHigh(protphysaddr)); 1601 |
|
1597 protgrp_blks = protgroup_len / 8; 1598 protgrp_bytes = protgrp_blks * blksize; 1599 | 1602 protgrp_blks = protgroup_len / 8; 1603 protgrp_bytes = protgrp_blks * blksize; 1604 |
1600 prot_bde->tus.f.bdeSize = protgroup_len; 1601 prot_bde->tus.f.bdeFlags = LPFC_PDE7_DESCRIPTOR; 1602 prot_bde->tus.w = le32_to_cpu(bpl->tus.w); | 1605 /* check if this pde is crossing the 4K boundary; if so split */ 1606 if ((pde7->addrLow & 0xfff) + protgroup_len > 0x1000) { 1607 protgroup_remainder = 0x1000 - (pde7->addrLow & 0xfff); 1608 protgroup_offset += protgroup_remainder; 1609 protgrp_blks = protgroup_remainder / 8; 1610 protgrp_bytes = protgroup_remainder * blksize; 1611 } else { 1612 protgroup_offset = 0; 1613 curr_prot++; 1614 } |
1603 | 1615 |
1604 curr_prot++; | |
1605 num_bde++; 1606 1607 /* setup BDE's for data blocks associated with DIF data */ 1608 pgdone = 0; 1609 subtotal = 0; /* total bytes processed for current prot grp */ 1610 while (!pgdone) { 1611 if (!sgde) { 1612 lpfc_printf_log(phba, KERN_ERR, LOG_BG, --- 35 unchanged lines hidden (view full) --- 1648 if (split_offset) 1649 break; 1650 1651 /* Move to the next s/g segment if possible */ 1652 sgde = sg_next(sgde); 1653 1654 } 1655 | 1616 num_bde++; 1617 1618 /* setup BDE's for data blocks associated with DIF data */ 1619 pgdone = 0; 1620 subtotal = 0; /* total bytes processed for current prot grp */ 1621 while (!pgdone) { 1622 if (!sgde) { 1623 lpfc_printf_log(phba, KERN_ERR, LOG_BG, --- 35 unchanged lines hidden (view full) --- 1659 if (split_offset) 1660 break; 1661 1662 /* Move to the next s/g segment if possible */ 1663 sgde = sg_next(sgde); 1664 1665 } 1666 |
1667 if (protgroup_offset) { 1668 /* update the reference tag */ 1669 reftag += protgrp_blks; 1670 bpl++; 1671 continue; 1672 } 1673 |
|
1656 /* are we done ? */ 1657 if (curr_prot == protcnt) { 1658 alldone = 1; 1659 } else if (curr_prot < protcnt) { 1660 /* advance to next prot buffer */ 1661 sgpe = sg_next(sgpe); 1662 bpl++; 1663 --- 6 unchanged lines hidden (view full) --- 1670 } 1671 1672 } while (!alldone); 1673 1674out: 1675 1676 return num_bde; 1677} | 1674 /* are we done ? */ 1675 if (curr_prot == protcnt) { 1676 alldone = 1; 1677 } else if (curr_prot < protcnt) { 1678 /* advance to next prot buffer */ 1679 sgpe = sg_next(sgpe); 1680 bpl++; 1681 --- 6 unchanged lines hidden (view full) --- 1688 } 1689 1690 } while (!alldone); 1691 1692out: 1693 1694 return num_bde; 1695} |
1696 |
|
1678/* 1679 * Given a SCSI command that supports DIF, determine composition of protection 1680 * groups involved in setting up buffer lists 1681 * 1682 * Returns: 1683 * for DIF (for both read and write) 1684 * */ 1685static int --- 2212 unchanged lines hidden --- | 1697/* 1698 * Given a SCSI command that supports DIF, determine composition of protection 1699 * groups involved in setting up buffer lists 1700 * 1701 * Returns: 1702 * for DIF (for both read and write) 1703 * */ 1704static int --- 2212 unchanged lines hidden --- |