aboutsummaryrefslogtreecommitdiff
path: root/target/ppc/helper.h
diff options
context:
space:
mode:
authorLucas Mateus Castro (alqotel) <lucas.araujo@eldorado.org.br>2022-05-24 11:05:34 -0300
committerDaniel Henrique Barboza <danielhb413@gmail.com>2022-05-26 17:11:33 -0300
commit2d9cba74ef72232189ac5611968c1b9045a3e1a7 (patch)
tree2ccfd94128649c16915807b36694f20c0c3b9d8d /target/ppc/helper.h
parentc29018cc7395fdb7efd5e21c6f6c4d9cfbcf9a3c (diff)
downloadqemu-2d9cba74ef72232189ac5611968c1b9045a3e1a7.zip
qemu-2d9cba74ef72232189ac5611968c1b9045a3e1a7.tar.gz
qemu-2d9cba74ef72232189ac5611968c1b9045a3e1a7.tar.bz2
target/ppc: Implemented xvf16ger*
Implement the following PowerISA v3.1 instructions: xvf16ger2: VSX Vector 16-bit Floating-Point GER (rank-2 update) xvf16ger2nn: VSX Vector 16-bit Floating-Point GER (rank-2 update) Negative multiply, Negative accumulate xvf16ger2np: VSX Vector 16-bit Floating-Point GER (rank-2 update) Negative multiply, Positive accumulate xvf16ger2pn: VSX Vector 16-bit Floating-Point GER (rank-2 update) Positive multiply, Negative accumulate xvf16ger2pp: VSX Vector 16-bit Floating-Point GER (rank-2 update) Positive multiply, Positive accumulate Signed-off-by: Lucas Mateus Castro (alqotel) <lucas.araujo@eldorado.org.br> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20220524140537.27451-6-lucas.araujo@eldorado.org.br> Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Diffstat (limited to 'target/ppc/helper.h')
-rw-r--r--target/ppc/helper.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/target/ppc/helper.h b/target/ppc/helper.h
index f38cdbe..4070c08 100644
--- a/target/ppc/helper.h
+++ b/target/ppc/helper.h
@@ -550,6 +550,11 @@ DEF_HELPER_5(XVI16GER2, void, env, vsr, vsr, acc, i32)
DEF_HELPER_5(XVI16GER2S, void, env, vsr, vsr, acc, i32)
DEF_HELPER_5(XVI16GER2PP, void, env, vsr, vsr, acc, i32)
DEF_HELPER_5(XVI16GER2SPP, void, env, vsr, vsr, acc, i32)
+DEF_HELPER_5(XVF16GER2, void, env, vsr, vsr, acc, i32)
+DEF_HELPER_5(XVF16GER2PP, void, env, vsr, vsr, acc, i32)
+DEF_HELPER_5(XVF16GER2PN, void, env, vsr, vsr, acc, i32)
+DEF_HELPER_5(XVF16GER2NP, void, env, vsr, vsr, acc, i32)
+DEF_HELPER_5(XVF16GER2NN, void, env, vsr, vsr, acc, i32)
DEF_HELPER_5(XVF32GER, void, env, vsr, vsr, acc, i32)
DEF_HELPER_5(XVF32GERPP, void, env, vsr, vsr, acc, i32)
DEF_HELPER_5(XVF32GERPN, void, env, vsr, vsr, acc, i32)
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059
/*
 * QEMU Block driver for RADOS (Ceph)
 *
 * Copyright (C) 2010 Christian Brunner <chb@muc.de>
 *
 * This work is licensed under the terms of the GNU GPL, version 2.  See
 * the COPYING file in the top-level directory.
 *
 */

#include "qemu-common.h"
#include "qemu-error.h"

#include "rbd_types.h"
#include "block_int.h"

#include <rados/librados.h>



/*
 * When specifying the image filename use:
 *
 * rbd:poolname/devicename
 *
 * poolname must be the name of an existing rados pool
 *
 * devicename is the basename for all objects used to
 * emulate the raw device.
 *
 * Metadata information (image size, ...) is stored in an
 * object with the name "devicename.rbd".
 *
 * The raw device is split into 4MB sized objects by default.
 * The sequencenumber is encoded in a 12 byte long hex-string,
 * and is attached to the devicename, separated by a dot.
 * e.g. "devicename.1234567890ab"
 *
 */

#define OBJ_MAX_SIZE (1UL << OBJ_DEFAULT_OBJ_ORDER)

typedef struct RBDAIOCB {
    BlockDriverAIOCB common;
    QEMUBH *bh;
    int ret;
    QEMUIOVector *qiov;
    char *bounce;
    int write;
    int64_t sector_num;
    int aiocnt;
    int error;
    struct BDRVRBDState *s;
    int cancelled;
} RBDAIOCB;

typedef struct RADOSCB {
    int rcbid;
    RBDAIOCB *acb;
    struct BDRVRBDState *s;
    int done;
    int64_t segsize;
    char *buf;
    int ret;
} RADOSCB;

#define RBD_FD_READ 0
#define RBD_FD_WRITE 1

typedef struct BDRVRBDState {
    int fds[2];
    rados_pool_t pool;
    rados_pool_t header_pool;
    char name[RBD_MAX_OBJ_NAME_SIZE];
    char block_name[RBD_MAX_BLOCK_NAME_SIZE];
    uint64_t size;
    uint64_t objsize;
    int qemu_aio_count;
    int event_reader_pos;
    RADOSCB *event_rcb;
} BDRVRBDState;

typedef struct rbd_obj_header_ondisk RbdHeader1;

static void rbd_aio_bh_cb(void *opaque);

static int rbd_next_tok(char *dst, int dst_len,
                        char *src, char delim,
                        const char *name,
                        char **p)
{
    int l;
    char *end;

    *p = NULL;

    if (delim != '\0') {
        end = strchr(src, delim);
        if (end) {
            *p = end + 1;
            *end = '\0';
        }
    }
    l = strlen(src);
    if (l >= dst_len) {
        error_report("%s too long", name);
        return -EINVAL;
    } else if (l == 0) {
        error_report("%s too short", name);
        return -EINVAL;
    }

    pstrcpy(dst, dst_len, src);

    return 0;
}

static int rbd_parsename(const char *filename,
                         char *pool, int pool_len,
                         char *snap, int snap_len,
                         char *name, int name_len)
{
    const char *start;
    char *p, *buf;
    int ret;

    if (!strstart(filename, "rbd:", &start)) {
        return -EINVAL;
    }

    buf = qemu_strdup(start);
    p = buf;

    ret = rbd_next_tok(pool, pool_len, p, '/', "pool name", &p);
    if (ret < 0 || !p) {
        ret = -EINVAL;
        goto done;
    }
    ret = rbd_next_tok(name, name_len, p, '@', "object name", &p);
    if (ret < 0) {
        goto done;
    }
    if (!p) {
        *snap = '\0';
        goto done;
    }

    ret = rbd_next_tok(snap, snap_len, p, '\0', "snap name", &p);

done:
    qemu_free(buf);
    return ret;
}

static int create_tmap_op(uint8_t op, const char *name, char **tmap_desc)
{
    uint32_t len = strlen(name);
    uint32_t len_le = cpu_to_le32(len);
    /* total_len = encoding op + name + empty buffer */
    uint32_t total_len = 1 + (sizeof(uint32_t) + len) + sizeof(uint32_t);
    uint8_t *desc = NULL;

    desc = qemu_malloc(total_len);

    *tmap_desc = (char *)desc;

    *desc = op;
    desc++;
    memcpy(desc, &len_le, sizeof(len_le));
    desc += sizeof(len_le);
    memcpy(desc, name, len);
    desc += len;
    len = 0; /* no need for endian conversion for 0 */
    memcpy(desc, &len, sizeof(len));
    desc += sizeof(len);

    return (char *)desc - *tmap_desc;
}

static void free_tmap_op(char *tmap_desc)
{
    qemu_free(tmap_desc);
}

static int rbd_register_image(rados_pool_t pool, const char *name)
{
    char *tmap_desc;
    const char *dir = RBD_DIRECTORY;
    int ret;

    ret = create_tmap_op(CEPH_OSD_TMAP_SET, name, &tmap_desc);
    if (ret < 0) {
        return ret;
    }

    ret = rados_tmap_update(pool, dir, tmap_desc, ret);
    free_tmap_op(tmap_desc);

    return ret;
}

static int touch_rbd_info(rados_pool_t pool, const char *info_oid)
{
    int r = rados_write(pool, info_oid, 0, NULL, 0);
    if (r < 0) {
        return r;
    }
    return 0;
}

static int rbd_assign_bid(rados_pool_t pool, uint64_t *id)
{
    uint64_t out[1];
    const char *info_oid = RBD_INFO;

    *id = 0;

    int r = touch_rbd_info(pool, info_oid);
    if (r < 0) {
        return r;
    }

    r = rados_exec(pool, info_oid, "rbd", "assign_bid", NULL,
                   0, (char *)out, sizeof(out));
    if (r < 0) {
        return r;
    }

    le64_to_cpus(out);
    *id = out[0];

    return 0;
}

static int rbd_create(const char *filename, QEMUOptionParameter *options)
{
    int64_t bytes = 0;
    int64_t objsize;
    uint64_t size;
    time_t mtime;
    uint8_t obj_order = RBD_DEFAULT_OBJ_ORDER;
    char pool[RBD_MAX_SEG_NAME_SIZE];
    char n[RBD_MAX_SEG_NAME_SIZE];
    char name[RBD_MAX_OBJ_NAME_SIZE];
    char snap_buf[RBD_MAX_SEG_NAME_SIZE];
    char *snap = NULL;
    RbdHeader1 header;
    rados_pool_t p;
    uint64_t bid;
    uint32_t hi, lo;
    int ret;

    if (rbd_parsename(filename,
                      pool, sizeof(pool),
                      snap_buf, sizeof(snap_buf),
                      name, sizeof(name)) < 0) {
        return -EINVAL;
    }
    if (snap_buf[0] != '\0') {
        snap = snap_buf;
    }

    snprintf(n, sizeof(n), "%s%s", name, RBD_SUFFIX);

    /* Read out options */
    while (options && options->name) {
        if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
            bytes = options->value.n;
        } else if (!strcmp(options->name, BLOCK_OPT_CLUSTER_SIZE)) {