1/*-
2 * Copyright 2009 Solarflare Communications Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
--- 10 unchanged lines hidden (view full) ---
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
27__FBSDID("$FreeBSD: head/sys/dev/sfxge/common/siena_vpd.c 278839 2015-02-16 06:12:04Z arybchik $");
28
29#include "efsys.h"
30#include "efx.h"
31#include "efx_types.h"
32#include "efx_regs.h"
33#include "efx_impl.h"
34
35#if EFSYS_OPT_VPD
--- 500 unchanged lines hidden (view full) ---
536 /* Allocated memory should have room for the new VPD */
537 if (hdr_length + vpd_length > dcfg_size) {
538 rc = ENOSPC;
539 goto fail3;
540 }
541
542 /* Copy in new vpd and update header */
543 vpd_offset = dcfg_size - vpd_length;
544 EFX_POPULATE_DWORD_1(dcfg->dynamic_vpd_offset, EFX_DWORD_0, vpd_offset);
545 memcpy((caddr_t)dcfg + vpd_offset, data, vpd_length);
546 EFX_POPULATE_DWORD_1(dcfg->dynamic_vpd_length, EFX_DWORD_0, vpd_length);
547
548 /* Update the checksum */
549 cksum = 0;
550 for (pos = 0; pos < hdr_length; pos++)
551 cksum += ((uint8_t *)dcfg)[pos];
552 dcfg->csum.eb_u8[0] -= cksum;
553
554 /* Erase and write the new sector */
--- 50 unchanged lines hidden ---
2 * Copyright 2009 Solarflare Communications Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
--- 10 unchanged lines hidden (view full) ---
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26#include <sys/cdefs.h>
27__FBSDID("$FreeBSD: head/sys/dev/sfxge/common/siena_vpd.c 278839 2015-02-16 06:12:04Z arybchik $");
28
29#include "efsys.h"
30#include "efx.h"
31#include "efx_types.h"
32#include "efx_regs.h"
33#include "efx_impl.h"
34
35#if EFSYS_OPT_VPD
--- 500 unchanged lines hidden (view full) ---
536 /* Allocated memory should have room for the new VPD */
537 if (hdr_length + vpd_length > dcfg_size) {
538 rc = ENOSPC;
539 goto fail3;
540 }
541
542 /* Copy in new vpd and update header */
543 vpd_offset = dcfg_size - vpd_length;
544 EFX_POPULATE_DWORD_1(dcfg->dynamic_vpd_offset, EFX_DWORD_0, vpd_offset);
545 memcpy((caddr_t)dcfg + vpd_offset, data, vpd_length);
546 EFX_POPULATE_DWORD_1(dcfg->dynamic_vpd_length, EFX_DWORD_0, vpd_length);
547
548 /* Update the checksum */
549 cksum = 0;
550 for (pos = 0; pos < hdr_length; pos++)
551 cksum += ((uint8_t *)dcfg)[pos];
552 dcfg->csum.eb_u8[0] -= cksum;
553
554 /* Erase and write the new sector */
--- 50 unchanged lines hidden ---